Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Regarding nested query #985

Open
pamit opened this issue Feb 1, 2015 · 0 comments
Open

Regarding nested query #985

pamit opened this issue Feb 1, 2015 · 0 comments

Comments

@pamit
Copy link

pamit commented Feb 1, 2015

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant