solr :term 查询, phrase查询, boolean 查询

来源:互联网 发布:数据分组分析法案例 编辑:程序博客网 时间:2024/04/30 08:54

搜索总体有:term 查询, phrase查询, boolean 查询

1. SOLR搜索覆盖度和准确度保证的三个搜索方式:

保证准确率: AND: Search for two different terms, new and house, requiring both to match 。完全相同逻辑的两种写法:(+new +house           new AND house )

保证覆盖率:OR : Search for two different terms, new and house, requiring only one to match 。solr默认的是OR搜索,所以(new or house,  new  house)结果一样

保证精准度: "":   Search for the exact phrase "new house" ,查询full phrase,则solr会考虑在 new AND house的结果集基础上,考虑new 和house之间的position。

保证覆盖率:Fuzzy matching 模糊搜索(包含:wildcard searching通配符搜索, range searching范围搜索, edit-distance searching编辑距离搜索, and proximity searching邻近搜索. )

其中,

(1)范围搜索例子如下:•  Query: yearsOld:[18 TO 21] Matches 18, 19, 20, 21 ;•  Query: title:[boat TO boulder] Matches boat, boil, book, boulder, etc. ;•  Query: price:[12.99 TO 14.99] Matches 12.99, 13.000009, 14.99, etc. ,范围用{}或[]或者[}或者{],同集合区间表示一样。

(2)编辑距离搜索中:编辑距离定义是An edit distance is defined as an insertion插入, a deletion删除, a substitution置换替换, ora transposition互换 of characters.

 例子如下:Query: administrator~1 Matches within one edit distance. •  Query: administrator~2 Matches within two edit distances. (T his is the default if no edit distance is provided.) •  Query: administrator~N Matches within N edit distances

(3)邻近搜索指的是搜索两个term之间的term:Query: "chief of ficer"~1 ,当你只记得短语的第一个和最后一个词的时候可以采用邻近搜索。邻近搜索的例子:Query: "chief of ficer"~N ---  Meaning: Finds chief within N positions of off icer.

2. SOLR提供的排除搜索:

NOT或者 -,都表示否定;如 中国  NOT 北京====中国  - 北京

3. SOLR支持野蛮查询:增加了搜索的灵活性

New AND (house OR (home NOT improvement NOT depot NOT grown)) 
(+(buying purchasing -renting) +(home house residence –(+property -bedroom))) 

不论用什么逻辑来搜索,solr都是先搜索每个term的结果集,然后进行逻辑操作返回真实结果


备注:为了和+   等符号区分,solr中将AND , OR描述为 binary operator

总体来说:越复杂的搜索越影响效率,所以采用哪种搜索以及设置的参数都需要经过分析,否则保证了业务搜索的效果而影响了性能。

0 0
原创粉丝点击