什么是正确的Solr模糊搜索语法?

时间:2016-05-17 11:02:29

标签: java solr lucene

我一直在尝试从java web服务中在Solr中进行模糊搜索,但是将〜添加到搜索查询中并不起作用。

我的非模糊查询如下:

((param_name : "gold") // Works return items with "gold" in it

为了使它模糊,我尝试添加〜多种方式,但似乎没有任何工作

((param_name : "glod~") // Adding inside quotes

((param_name : "glod"~) // Adding outside quotes

((param_name : "glod"\~)) // Escaping

只有实际工作的东西根本不是添加引号,但我必须添加引号以便特殊字符等起作用。

((param_name : glod~)) // works, returns matching results

有人有任何想法吗?

1 个答案:

答案 0 :(得分:0)

是的,您需要手动转义特殊字符。

要逃避这些角色,请在角色前使用\。

Solr引号用于短语。

如果你想组合模糊短语搜索,你需要做:

((param_name : glod~) AND param_name : glod~))

((param_name : glod~))是一种正确的做法。

执行此操作"gold year"~10将运行邻近搜索。 例如,搜索" 黄金"和" "在文档中彼此10个字之内使用搜索

相关问题