solr 查询中的加号未正确处理

Kua*_*uan 2 solr

全部:

我是 Solr 的新手,当我使用 solr 示例导入一些随机文档时,我在 q 中使用搜索查询,如下所示:

fund+report
Run Code Online (Sandbox Code Playgroud)

fund和+之间没有空格,我以为会在文档中搜索“fund+report”这个词,这种情况在文档中很少发生,但返回的结果很多,查询url是:

http://localhost:8983/solr/collection1/select?q=fund%2Breport&fl=id+filename+%5Bexplain%5D&wt=xml&indent=true
Run Code Online (Sandbox Code Playgroud)

我认为 Solr 对待我的查询就像:

fund report
Run Code Online (Sandbox Code Playgroud)

或者

fund OR report
Run Code Online (Sandbox Code Playgroud)

谁能告诉我为什么 solr 会这样对待我的查询?我怎样才能让solr将fund+report视为一个词?

谢谢

Dav*_*ber 5

HTTP 调用将简单地将 转换+为空格。如果您需要一个实际的+符号,那么您需要使用 URL 编码值+(我认为是%2B)。如果您正在查找短语 “基金报告”,那么您需要在该短语两边加上双引号,例如"fund report"。这些也应该是 URL 编码的(我认为其值是%22)。

请记住,如果您使用词干提取,那么搜索"fund report"将找到"funds reports""funding reports"等的结果。但这也许就是您想要的。

总而言之,您的 URL 可能如下所示:

http://localhost:8983/solr/collection1/select?q=%22fund%20report%22&fl=id,filename,%5Bexplain%5D&wt=xml&indent=true
Run Code Online (Sandbox Code Playgroud)

请注意,为参数列出的字段fl应以逗号分隔。我不知道为什么你的字段周围有方括号explain