我试图运行此_search
查询:
{
"query": {
"range": {
"created_time": {
"gt": "now-24h"
}
},
"terms": {
"from_id": [
"144458",
"112275"
]
}
}
}
但它会返回此错误:
{
error: SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[GAIodkFdTI-mHRS2_IE-JQ][content][0]: SearchParseException[[content][0]: query[created_time:{1409011409797 TO *]],from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"range":{"created_time":{"gt":"now-24h"}},"terms":{"from_id":["144458","112275"]}}}]]]; nested: ElasticsearchParseException[Expected field name but got START_OBJECT "terms"]; }]
status: 400
}
如果我删除range
阻止或terms
阻止,则可以正常工作。他们只有在一起努力时才能工作。
这是elasticsearch的问题吗?这可能吗?
答案 0 :(得分:10)
我认为你需要一个布尔查询。您不能在同一"查询"下放置两个查询。键。
如果您想要AND两个查询,那么这应该有效:
{
"query": {
"bool": {
"must": [
{
"range": {
"created_time": {
"gt": "now-24h"
}
}
},
{
"terms": {
"from_id": [
"144458",
"112275"
]
}
}
]
}
}
}