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

**URL:** <https://discuss.elastic.co/t/elastic-search-tire-equivalent-of-scoping-scalar-fields-in-sunspot/10538>\
**Category:** Elasticsearch\
**Created:** [January 29, 2013, 12:53pm UTC](https://discuss.elastic.co/t/elastic-search-tire-equivalent-of-scoping-scalar-fields-in-sunspot/10538 "2013-01-29T12:53:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manoj\_Mathai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manoj_mathai/32/2509_2.png) [@Manoj\_Mathai](https://discuss.elastic.co/u/Manoj_Mathai)\
**Post date:** [January 29, 2013, 12:53pm UTC](https://discuss.elastic.co/t/elastic-search-tire-equivalent-of-scoping-scalar-fields-in-sunspot/10538/1 "2013-01-29T12:53:30Z")

</div>

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](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:54am UTC](https://discuss.elastic.co/t/elastic-search-tire-equivalent-of-scoping-scalar-fields-in-sunspot/10538/2 "2017-07-06T02:54:12Z")

</div>

Closed on July 6, 2017, 2:54am UTC


