根据文档,我使用的是这种语法:
self.search(
query: {
bool: {
must: { match: { type: 'user' } },
must: { match: { status: status } },
must: { range: { created_at: { from: date_from, to: date_to } } }
}
},
size: 1000
)
我认为它应该寻找所有3个条件,但查询忽略了所有must
但最后:
<Elasticsearch::Model::Searching::SearchRequest:0x000000039b2c08
@definition=
{:index=>"uusers",
:type=>"user",
:body=>{:query=>{:bool=>{:must=>{:range=>{:created_at=>{:from=>Mon, 25 Aug 2014, :to=>Thu, 18 May 2017}}}}}, :size=>1000}}
我做错了什么?
答案 0 :(得分:1)
如果有多个语句,则必须将其添加到数组中,如下所示:
self.search(
query: {
bool: {
must: [
{ match: { type: 'user' } },
{ match: { status: status } },
{ range: { created_at: { from: date_from, to: date_to } } }
]
}
},
size: 1000
)