我正在尝试在elasticsearch中编写一个查询,并在多个字段上进行完全匹配
我对单个字段的完全匹配有以下查询:
GET /index/data/_search
{
"query": {
"term": {
"table":"abc"
}
}
}
这里的关键是“table”,值为“abc”。我想添加另一个名为“chair”的键,其值为“def for exact match query。
”答案 0 :(得分:5)
使用bool + must或bool + filter查询,两者都充当逻辑和运算符:
GET /index/data/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"table":"abc"
},
{
"term": {
"chair":"def"
}
]
}
}
}