基于 metadata_storage_path Azure 搜索的筛选

Filtering based on metadata_storage_path Azure Search

我想根据特定路径过滤结果,例如“/container/folder1”,但是我使用 metadata_storage_path 作为我的文档密钥,因此默认情况下它被加密为 base64。
我已尝试根据加密值创建过滤器,但这似乎不起作用,例如 "filter": "metadata_storage_path eq 'aHR0cHM6Ly9hemRdasb2IuYmxvYi5jb3JdpbmRvd3sL3NlYXJjaddkZXIsad=='",。我想这是因为 base64 编码路径包含的特殊字符。 有没有办法根据这个 base 64 编码的元数据路径进行过滤? 我也尝试过使用 base64decode 函数,并使用字段映射将元数据存储路径映射到解码字段,但每次我重新 运行 索引器时它 returns 一个错误,看起来文档键实际上不能被解码。 任何帮助将不胜感激。

我在使用 base64decode 函数时遇到的错误。

'metadata_storage_path': The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. '

从报错信息来看,您应该检查base64string的长度是否是4的倍数并且base64string是否有效。

一个Base64字符串只会由字符'A'..'Z', 'a'..'z', '0'..'9', '+', '/'组成,通常在末尾补上最多两个'=',使长度为a 4 的倍数。

你原来的base64string长度是62,不是4的倍数,你应该删除最后两个"="填充字符使base64string有效。