我已经构建了以下ElasticSearch(POST)查询,以便获取符合以下条件的记录: 选择类型:“服务器” -select字段:“服务器名”,“筒仓”,“ packages.displayname”,“ packages.displayversion”,“环境”
{
"size": 10,
"_source" : ["servername", "silo", "packages.displayname", "packages.displayversion","environment"],
"query": {
"type" : {
"value" : "server"
}
}
}
有效!
问题是当我想添加以下条件时: -“ packages.displayname” =“谷歌浏览器”
{
"size": 10,
"_source" : ["servername", "silo", "packages.displayname", "packages.displayversion","environment"],
"query": {
"type" : {
"value" : "server"
},
"match" : {"packages.displayname" : "Google Chrome"}
}
}
它不起作用!引发以下错误:
"type": "parsing_exception",
"reason": "[type] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 8,
"col": 9
我在ElasticSearch中完全是菜鸟。有人可以帮我弄清楚我应该如何编写Query吗?
谢谢
答案 0 :(得分:0)
您必须构建一个布尔查询:
{
"query": {
"bool": {
"must": {
"match": {
"packages.displayname": "Google Chrome"
}
},
"must": {
"type": {
"value": "server"
}
}
}
}
}