2016-08-23 9 views
1

私はChewy gemを始めたばかりですが、すばらしいアイデアのようですが、基本的なクエリーでもうまく動作することはできません。Chewy gemはどのように結果をフィルタリングするのですか?

私はLeadsIndexとして私のリードモデルを索引付けしました。 ここで私は作品のクエリがあります

irb(main):068:0> LeadsIndex.filter.first 
    LeadsIndex Search (8.9ms) {:body=>{}, :index=>["leads"], :type=>[]} 
=> #<LeadsIndex::Lead:0x007ff76324cbf8 @attributes={"id"=>"14", "name"=>"Victoria Roob", "_score"=>1.0, "_explanation"=>nil}, 
             @_data={"_index"=>"leads", "_type"=>"lead", "_id"=>"14", "_score"=>1.0, "_source"=>{"name"=>"Victoria Roob"}}> 

をしかし、私はそれに非常にレコードの検索をしようとすると、それは結果を示しています

irb(main):071:0> LeadsIndex.filter { name == "Victoria Roob" }.first 
    LeadsIndex Search (7.4ms) {:body=>{:query=>{:filtered=>{:query=>{:match_all=>{}}, :filter=>{:term=>{"name"=>"Victoria Roob"}}}}}, :index=>["leads"], :type=>[]} 
=> nil 

私が何か間違ったことをやっていますか?

答えて

0

次のいずれかの一致フレーズができます。他に

LeadsIndex.query(match_phrase: {name: "Victoria Root"}).first 

またはクエリを一緒にチェーン:

LeadsIndex.filter { name == "Victoria" }.filter { name == "Roob" }.first 
関連する問題