我的查询有什么问题?我只想查询以返回具有以下条件的文档: language_id = 28和[225,226,227]中的publisher_id,最后计算统计数据。我是这样做的:
{
"query": {
"filtered": {
"query": {
"term": {
"language_id": 28
}
},
"filter": {
"and": [
{
"range": {
"re_max": {
"gt": 100
}
}
},
"terms": {
"publihser_id": [
225,
226,
227
]
}
}
]
}
}
},
"aggs": {
"stat_agg": {
"stats": {
"field": "re_max"
}
}
}
}
它产生了一个错误:
{"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[CebklbvjR2ORQkaiUEm6eQ][rep][0]: SearchParseException[[rep][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [ {\r\n \"query\": {\r\n \"filtered\": {\r\n \"query\": {\r\n \"term\": {\r\n \"language_id\": 28\r\n }\r\n },\r\n \"filter\": {\r\n \"and\": [\r\n {\r\n \"range\": {\r\n \"re_max\": {\r\n \"gt\": 100\r\n }\r\n }\r\n },\r\n \"terms\": {\r\n \"publihser_id\": [\r\n 225,\r\n 226,\r\n 227\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n },\r\n \"aggs\": {\r\n \"stat_agg\": {\r\n \"stats\": {\r\n \"field\": \"re_max\"\r\n }\r\n }\r\n }\r\n }]]]; nested: QueryParsingException[[rep] Failed to parse]; nested: JsonParseException[Unexpected character (':' (code 58)): was expecting comma to separate ARRAY entries\n at [Source: [B@d78a10f; line: 18, column: 23]]; }{[CebklbvjR2ORQkaiUEm6eQ][rep][4]: SearchParseException[[rep][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [ {\r\n \"query\": {\r\n \"filtered\": {\r\n \"query\": {\r\n \"term\": {\r\n \"language_id\": 28\r\n }\r\n },\r\n \"filter\": {\r\n \"and\": [\r\n {\r\n \"range\": {\r\n \"re_max\": {\r\n \"gt\": 100\r\n }\r\n }\r\n },\r\n \"terms\": {\r\n \"publihser_id\": [\r\n 225,\r\n 226,\r\n 227\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n },\r\n \"aggs\": {\r\n \"stat_agg\": {\r\n \"stats\": {\r\n \"field\": \"re_max\"\r\n }\r\n }\r\n }\r\n }]]]; nested: QueryParsingException[[rep] Failed to parse]; nested: JsonParseException[Unexpected character (':' (code 58)): was expecting comma to separate ARRAY entries\n at [Source: [B@d78a10f; line: 18, column: 23]]; }{[CebklbvjR2ORQkaiUEm6eQ][rep][3]: SearchParseException[[rep][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [ {\r\n \"query\": {\r\n \"filtered\": {\r\n \"query\": {\r\n \"term\": {\r\n \"language_id\": 28\r\n }\r\n },\r\n \"filter\": {\r\n \"and\": [\r\n {\r\n \"range\": {\r\n \"re_max\": {\r\n \"gt\": 100\r\n }\r\n }\r\n },\r\n \"terms\": {\r\n \"publihser_id\": [\r\n 225,\r\n 226,\r\n 227\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n },\r\n \"aggs\": {\r\n \"stat_agg\": {\r\n \"stats\": {\r\n \"field\": \"re_max\"\r\n }\r\n }\r\n }\r\n }]]]; nested: QueryParsingException[[rep] Failed to parse]; nested: JsonParseException[Unexpected character (':' (code 58)): was expecting comma to
答案 0 :(得分:0)
它应该是这样的(语法明智的) - 你错过了一个" {":
{
"query": {
"filtered": {
"query": {
"term": {
"language_id": 28
}
},
"filter": {
"and": [
{
"range": {
"re_max": {
"gt": 100
}
}
},
{
"terms": {
"publihser_id": [
225,
226,
227
]
}
}
]
}
}
},
"aggs": {
"stat_agg": {
"stats": {
"field": "re_max"
}
}
}
}