要求:短语之间的词距搜索,并将搜索结果高亮显示
现在的问题是:如果涉及多个短语,那么第二个短语开始就会收到分词影响
例子:"hello world" #N100 "love you",这个查询会转变为下面的 ES 查询语句
- 现在的问题,love you 也被分词了,love 和 you 两个词影响了结果
- hello world 和 you ,hello world 和 love 都被高亮出来
- 结果应该包含 hello world 和 love you ,但是现在结果包含 hello world 和 love ,包含 hello world 和 you 的结果也被检索出来了
- es 的检索式如下
{
"bool" : {
"must" : [
{
"bool" : {
"must" : [
{
"bool" : {
"should" : [
{
"match_phrase" : {
"fileContent" : {
"query" : "\"hello world\" \"love you\"",
"slop" : 100,
"zero_terms_query" : "NONE",
"boost" : 2.0
}
}
},
{
"match_phrase" : {
"fileContent" : {
"query" : "\"love you\" \"hello world\"",
"slop" : 100,
"zero_terms_query" : "NONE",
"boost" : 2.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}