Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created August 12, 2012 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahemoff/3332033 to your computer and use it in GitHub Desktop.
Save mahemoff/3332033 to your computer and use it in GitHub Desktop.
tire search
# search by tag
tire.search(per_page: params[:per_page]||20) {
query do
boolean do
must { term 'keywords', keyword} if keyword.present?
must { term 'tags', tag} if tag.present?
must { string q } if q.present?
end
end
highlight 'title', 'description'
}
# popular tags
tire.search do
facet 'tags' do
terms :tags, size: options[:limit]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment