# Elasticsearch and multilanguage attributes

**URL:** <https://discuss.elastic.co/t/elasticsearch-and-multilanguage-attributes/12245>\
**Category:** Elasticsearch\
**Created:** [June 3, 2013, 10:39pm UTC](https://discuss.elastic.co/t/elasticsearch-and-multilanguage-attributes/12245 "2013-06-03T22:39:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![oto\_iashvili](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@oto\_iashvili](https://discuss.elastic.co/u/oto_iashvili)\
**Post date:** [June 3, 2013, 10:39pm UTC](https://discuss.elastic.co/t/elasticsearch-and-multilanguage-attributes/12245/1 "2013-06-03T22:39:52Z")

</div>

Hi,

I m using rails and elasticsearch. My object "product" have a title and a  
text in different language and also a price and a category

here what im currently doing. it is working, but very slow

mapping do  
indexes :id, type: 'integer', :index =\> :not\_analyzed  
indexes :sousrubrique\_id, type: 'integer', :index =\> :not\_analyzed  
indexes :price, type: 'float', :index =\> :not\_analyzed

```
Language.get_mapping_langues.each do |idl, value|
  class_eval <<-RUBY
    indexes :title_#{value}, :as => lambda { |product| 

```

product.attributes['title\_' + value] unless  
product.attributes['date\_validation\_' + value].nil? }  
indexes :text\_#{value}, :as =\> lambda { |product|  
product.attributes['text\_' + value] unless  
product.attributes['date\_validation\_' + value].nil?}  
RUBY  
end  
end

* * *

```
tire.search(:page => (prms[:page] || 1)) do
  query do
    filtered {
      query { string mc} unless mc.blank?
      filter :term, :sousrubrique_id => prms[:sousrubrique_id] unless 

```

prms[:sousrubrique\_id].blank?  
filter :range, {:prix\_local\_objet =\> {:from =\>  
prms[:price][:max], :to =\> prms[:price][:min]}}  
}  
end  
end

but when I make a search, then it will search in all language, when  
actually I would like only for the current language, which should be  
quicklier.

is there a way to do that ? Or should I create one index for each language  
? But if such, how to tell which index to use for callback when I delete or  
edit or create a product ?

thanks

--  
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:33am UTC](https://discuss.elastic.co/t/elasticsearch-and-multilanguage-attributes/12245/2 "2017-07-06T02:33:12Z")

</div>


