我正在尝试运行此_search查询:
{
"query": {
"range": {
"created_time": {
"gt": "now-24h"
}
},
"terms": {
"from_id": [
"144458",
"112275"
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
但它返回此错误:
{
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
}
Run Code Online (Sandbox Code Playgroud)
如果我删除range块或terms块,它工作正常.它们只在一起尝试时才起作用.
这是弹性搜索的问题吗?这可能吗?
Raf*_*ida 10
我认为你需要一个布尔查询.您不能在同一"查询"键下放置两个查询.
如果你想要AND两个查询,那么这应该工作:
{
"query": {
"bool": {
"must": [
{
"range": {
"created_time": {
"gt": "now-24h"
}
}
},
{
"terms": {
"from_id": [
"144458",
"112275"
]
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1990 次 |
| 最近记录: |