Elastic Search/tire equivalent of "Scoping (Scalar Fields)" in sunspot

I'm exploring various options for a search engine for our rails-app/data. I
was able to make sunspot/solr work and I'm currently exploring
ElasticSearch as an alternative, but couldn't get the same
thing(scoping/filtering) to work.

I would like to filter/scope objects as described in the "Scoping (Scalar
Fields)" section in 'https://github.com/sunspot/sunspot'. Not sure if
'filters' in Elastic Search mean the same thing.

I have an active record class 'Product'.

class Product < ActiveRecord::Base
...

  include Tire::Model::Search
  include Tire::Model::Callbacks

  tire.mapping do
    indexes :name, :type => :string
    indexes :categories do
      indexes :id, :type => :integer
    end
  end
end

Once I imported products into ES,

the following query works and gives results

Product.tire.search { query { string '*', default_operator: "AND", 

default_field: "name" } }.results

How do I get products of a particular category given a category id ?

Product.tire.search { query { string '*', default_operator: "AND", 

default_field: "name" }; filter(:term, 'categories.id' => 38) }.results

I'm basically looking for the tire equivalent for the following sunspot
call:

Product.search do
  with(:category_ids, 38)
end

with the following in the Product class

searchable :auto_index => true, :auto_remove => true do
  text :name

  integer :category_ids, :multiple => true do
     self.categories.map &:id
  end

end

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.