Skip to content

Instantly share code, notes, and snippets.

@xeago
Created August 21, 2012 09:54
Show Gist options
  • Save xeago/3414106 to your computer and use it in GitHub Desktop.
Save xeago/3414106 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'Tire'
search = Tire.search('videos')
search.filter :term, "status" => "REMOVED"
# search.size 100
p search.results.map.all? {|v| v.status == "REMOVED" }
search.results.map.each { |v| puts v.status }
puts search.to_curl
# Tire.index 'videos'
create :mappings => {
:video => {
:properties => {
:id => {:index => :not_analyzed},
:user_id => {:index => :not_analyzed},
:likes => {:index => :not_analyzed, :type => 'integer'},
:title => {:type => 'string', :analyzer => 'keyword'},
:tags => {:type => 'string', :analyzer => 'keyword'},
:status => {:type => 'string', :analyzer => 'keyword' },
:user_status => {:type => 'string', :analyzer => 'keyword' },
:playable => {:type => 'boolean', :analyzer => 'keyword'},
:manual_check => {:type => 'string', :analyzer => 'keyword' },
:auto_check => {:type => 'boolean'},
:created_at => {:type => 'date' },
:published_at => {:type => 'date' }
}
}
}
false
REMOVED
REMOVED
REMOVED
PUBLISHED
PUBLISHED
PUBLISHED
NOT_PUBLISHED
REMOVED
PUBLISHED
REMOVED
curl -X GET "http://localhost:9200/videos/_search?pretty=true" -d '{"filter":{"term":{"user_status":"DISABLED"}}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment