retire icon indicating copy to clipboard operation
retire copied to clipboard

Regarding nested query

Open pamit opened this issue 10 years ago • 0 comments

Hi,

I have a 'Tweet' model which belongs to a 'Profile' model. Tweet(:title, :text, :profile_id) Profile(:name, :visits)

I need to search for tweets which has a profile with specific name such as 'xxx' The following is my code which does not work:

mapping do indexes :id, index: :not_analyzed indexes :profile_id, index: :not_analyzed indexes :title, analyzer: 'snowball', boost: 100 indexes :text, analyzer: 'snowball' indexes :created_at, type: 'date', index: :not_analyzed indexes :profile do indexes :id, index: :not_analyzed indexes :name, analyzer: 'snowball' end
end

def self.search (q, page) tire.search(load: true, :per_page => 10, :page => page) do query { string (q + "*"), default_operator: "AND" } if q.present? filter :range, created_at: {lte: Time.zone.now} # filter :terms, :profile_id => [1,2,3], :execution => 'or' ### this works! # filter :terms, 'profile.name' => ['Payam','Navid'] ### this does not work! end end

Please help me. Thank you in advance.

pamit avatar Feb 01 '15 14:02 pamit