我正在针对弹性搜索运行查询,但返回的结果错误。我的想法是,我可以使用单个查询来检查一系列字段。但是,当我通过以下查询时,将返回不包含所包含的商品的商品。
query: {
bool: {
must: [
{match:{"lineup.name":{query:"The 1975"}}}
]
}
}
Run Code Online (Sandbox Code Playgroud)
对象是看起来像的事件。
{
title: 'Glastonbury'
country: 'UK',
lineup: [
{
name: 'The 1975',
genre: 'Indie',
headliner: false
}
]
},
{
title: 'Reading'
country: 'UK',
lineup: [
{
name: 'The Strokes',
genre: 'Indie',
headliner: true
}
]
}
Run Code Online (Sandbox Code Playgroud)
就我而言,这两个事件均返回。
可以在这里看到映射:https : //jsonblob.com/567e8f10e4b01190df45bb29
您需要使用match_phrase查询,match查询要查找The或1975,并且在The strokes中找到The,它会为您提供结果。
尝试
{
"query": {
"bool": {
"must": [
{
"match": {
"lineup.name": {
"query": "The 1975",
"type": "phrase"
}
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1356 次 |
| 最近记录: |