如何知道在elasticsearch中匹配了哪些关键字
how to know which keywords matched in elasticsaearch
说我查询:
POST /story/story/_search
{
"query":{
"bool":{
"should":[
{
"match":{
"termVariations":{
"query":"not driving",
"type":"boolean",
"operator":"AND"
}
}
},
{
"match":{
"termVariations":{
"query":"driving",
"type":"boolean",
"operator":"AND"
}
}
}
]
}
}
}
此查询 return 由一个分析器或另外 3 个文档编辑。
我如何判断匹配了哪个 should 子句? Elasticsearch 可以 return 匹配的短语和结果吗?
谢谢!
谢谢@keety! highlight 正是我要找的!! :-)
这里最好的选择是named queries。
您可以命名您的查询,匹配的查询的名称将按文档提供。
{
"query": {
"bool": {
"should": [
{
"match": {
"name.first": {
"query": "qbox",
"_name": "first"
}
}
},
{
"match": {
"name.last": {
"query": "search",
"_name": "last"
}
}
}
]
}
}
}
说我查询:
POST /story/story/_search
{
"query":{
"bool":{
"should":[
{
"match":{
"termVariations":{
"query":"not driving",
"type":"boolean",
"operator":"AND"
}
}
},
{
"match":{
"termVariations":{
"query":"driving",
"type":"boolean",
"operator":"AND"
}
}
}
]
}
}
}
此查询 return 由一个分析器或另外 3 个文档编辑。 我如何判断匹配了哪个 should 子句? Elasticsearch 可以 return 匹配的短语和结果吗?
谢谢!
谢谢@keety! highlight 正是我要找的!! :-)
这里最好的选择是named queries。 您可以命名您的查询,匹配的查询的名称将按文档提供。
{
"query": {
"bool": {
"should": [
{
"match": {
"name.first": {
"query": "qbox",
"_name": "first"
}
}
},
{
"match": {
"name.last": {
"query": "search",
"_name": "last"
}
}
}
]
}
}
}