我有一个书索引,用于存储书的全文内容(删除了停用词,但这对我的问题并不重要)。 我有以下查询:
Intent intent = new Intent(this, 3rdClass.class); // this is your current Activity's reference.
currentActivity.startActivity(intent);
对于所有具有最高分数的完整字符串的文档,如果具有较低分数,则具有一个或多个匹配项的所有文档均得到匹配:首先匹配的是具有很高分数的“安娜·卡列尼娜”,然后是所有具有其中有“快乐”,“家庭”。 我想获得什么:
我很难找到方法。
答案 0 :(得分:1)
完全匹配和部分匹配不能有条件地返回。 您可以使用named queries在客户端检查匹配项是完全匹配还是部分匹配。
GET books/_search
{
"query": {
"bool": {
"should": [
{
"match_phrase": {
"body": {
"query": "all happy families are alike",
"_name":"exact_match" ---> name of query(can be anything)
}
}
},
{
"match": {
"body": {
"query": "all happy families are alike",
"_name":"partial_match"
}
}
}
]
}
}
}
结果:
"hits" : [
{
"_index" : "books",
"_type" : "_doc",
"_id" : "4i0MeG0BCVIM-bi3Fif1",
"_score" : 4.1589947,
"_source" : {
"title" : "Anna Karenina",
"body" : "all happy families are alike"
},
"matched_queries" : [ ---> returns name of queries where condition matched
"exact_match",
"partial_match"
]
},
{
"_index" : "books",
"_type" : "_doc",
"_id" : "4y0MeG0BCVIM-bi3aScM",
"_score" : 0.44216567,
"_source" : {
"title" : "book 1",
"body" : "happy alike"
},
"matched_queries" : [ ---> returns name of queries where condition matched
"partial_match"
]
}
]
}