我进行了很多搜索,但案件一无所获。
我有关于 flex 搜索的帖子。我想得到的帖子
我用了这个但是没用。它检索创建的> 1524722310000的所有帖子,并且不检查 author_id 和 post_id !
query: {
bool: {
should: [
{match: {"author_id" : 2}},
{match: {"post_id" : 2}}
],
filter: [
{range: {"created": {gte : startTime , lte:targetTime}}},
]
}
}
最佳答案
您快到了,您只缺少一件事,即指定至少一个should
子句应该匹配,您可以这样做:
query: {
bool: {
minimum_should_match: 1, <-- add this line
should: [
{match: {"author_id" : 2}},
{match: {"post_id" : 2}}
],
filter: [
{range: {"created": {gte : startTime , lte:targetTime}}},
]
}
}
关于elasticsearch - 使用范围elasticsearch一起查询“AND”和“OR”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50036530/