我正在尝试执行Elasticsearch查询,该查询搜索文本字段(“ body”)并返回与我提供的两个多字词至少一个匹配的项(即:“ stack stackover”或“ stackoverflow”) 。我还希望查询仅提供在给定时间戳记之后发生的结果,并且结果按时间排序。
我当前的解决方案如下。我相信必须(在时间戳记上)正确地工作,但是BOOL +应该带有两个match_phrases是不正确的。我收到以下错误:
Unexpected character ('{' (code 123)): was expecting double-quote to start field name
我认为是因为我在那里有两个match_phrases?
This是ES映射,我正在使用的ES API的详细信息是here。
{"query":
{"bool":
{"should":
[{"match_phrase":
{"body":"a+phrase"}
},
{"match_phrase":
{"body":"another+phrase"}
}
]
},
{"bool":
{"must":
[{"range":
{"created_at:
{"gte":"thispage"}
}
}
]}
}
},"size":10000,
"sort":"created_at"
}