Skip to content

Instantly share code, notes, and snippets.

@JKring
Created May 30, 2013 02:32
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 JKring/5675407 to your computer and use it in GitHub Desktop.
Save JKring/5675407 to your computer and use it in GitHub Desktop.
long query
query = {:per_page=>15, :page=>1, :blacklisted=>false, :not_team_ids=>["5090770bd6841267b10004b4"], :search_terms=>nil, :sort=>[:team_scores_5090770bd6841267b10004b4_num_overall, :desc]}
solrquery = Writer.search do
all_of do
without(:removed).equal_to(true)
without(:blacklisted).equal_to(true) if query[:blacklisted] == false
with(:has_photo).equal_to(true) if query[:has_photo]
with(:team_ids).any_of(query[:team_ids]) if query[:team_ids]
without(:team_ids).any_of(query[:not_team_ids]) if query[:not_team_ids]
with(:group_ids).any_of([query[:group_ids]]) if query[:group_ids]
end
if query[:search_terms].blank?
order_by(query[:sort][0], query[:sort][1])
else
fulltext query[:search_terms]
end
paginate(:page => query[:page], :per_page => query[:per_page])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment