Skip to content

Instantly share code, notes, and snippets.

@chrislerum
Created July 6, 2016 19:38
Show Gist options
  • Save chrislerum/f8569dd37d1a279ee88383343e9cfc85 to your computer and use it in GitHub Desktop.
Save chrislerum/f8569dd37d1a279ee88383343e9cfc85 to your computer and use it in GitHub Desktop.
how to structure builder so filter requires both hidden be false AND approved be true?
right now, 'approved' just replaces the 'hidden' line.
query = Jbuilder.encode do |json|
json.query do
json.multi_match do
json.query term
json.fields ['title^2', 'description', 'tags.name']
end
end
json.filter do
json.term hidden: false
json.term approved: true
end
end
"{\"query\":{\"multi_match\":{\"query\":\"michigan\",\"fields\":[\"title^2\",\"description\",\"tags.name\"]}},\"filter\":{\"term\":{\"approved\":true}},\"aggs
\":{\"tags\":{\"terms\":{\"field\":\"tags.name\"}}}}"
# 'approved' shows up but not 'hidden'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment