Elastic Search中的多个“匹配短语”查询
这对我来说应该是显而易见的,但事实并非如此。以下两个仅匹配第二个阶段(在这种情况下为Cape Basin
)
"query": { "match_phrase": {
"contents": {
"query": "St Peter Fm",
"query": "Cape Basin"
}
}
}
"query": {
"match_phrase": {
"contents": {
"query": ["St Peter Fm", "Cape Basin"]
}
}
}
而以下错误发出错误消息
"query": { "match_phrase": {
"contents": {
"query": "St Peter Fm"
},
"contents": {
"query": "Cape Basin"
}
}
}
我想匹配包含的所有文件 输入完全相同的词组。
回答:
您的第一个查询实际上不是有效的JSON对象,因为您两次使用相同的字段名称。
您可以使用布尔必须查询来匹配两个短语:
PUT phrase/doc/1{
"text": "St Peter Fm some other text Cape Basin"
}
GET phrase/_search
{
"query": {
"bool": {
"must": [
{"match_phrase": {"text": "St Peter Fm"}},
{"match_phrase": {"text": "Cape Basin"}}
]
}
}
}
以上是 Elastic Search中的多个“匹配短语”查询 的全部内容, 来源链接: utcz.com/qa/425397.html