拥有这样的数据:{ "id" : 22, "name" : "test", "tagIds" : [ 2, 35, 56, 59 ] }
,如何搜索名称和标记?
使用以下查询:
{
"from": 0,
"size": 100,
"query": {
"terms": {
"tagIds": [
35
]
},
"multi_match": {
"query": "test",
"fields": [
"name"
]
}
}
}
获取此解析异常:[terms] malformed query, expected [END_OBJECT] but found [FIELD_NAME]
如何在流利的巢中正确写出这个?
答案 0 :(得分:1)
您需要使用bool query来组合多个查询。因此,您的查询应如下所示:
{
"from": 0,
"size": 100,
"query": {
"bool": {
"must": [
{
"terms": {
"tagIds": [
35
]
}
},
{
"multi_match": {
"query": "test",
"fields": [
"name"
]
}
}
]
}
}
}