algolia / algoliasearch-rails

AlgoliaSearch integration to your favorite ORM
MIT License
410 stars 118 forks source link

Algolia with globalize gem #283

Open jonhue opened 6 years ago

jonhue commented 6 years ago

I am using the globalize gem in my app, to translate a couple of columns in my database tables.

When Algolia indexes them, it only pics up the English translation. That leads to a problem, when a user uses another language and tries to search for some records.

Is Algolia able to handle records with attributes, that have multiple translations - and then utilize one of them when a search occurs?

casiodk commented 6 years ago

+1 Is there any progress here. What is the recomended way for indexing multiple indices per locale?

severin commented 6 years ago

+1 also interested in this

jonhue commented 6 years ago

@redox Is there a way to perform globalized searches with Algolia?

redox commented 6 years ago

Hey @jonhue @casiodk @severin;

sorry for being late here... I've never used the globalize gem so I don't have a lot of insights; but I assume having something like the following should work:

algoliasearch do
  [:en, :fr, :de].each do |lang|
    add_attribute "title_#{lang}" do
      Globalize.with_locale(lang) do
          title
      end
    end
  end
end

What do you think?

Spone commented 5 years ago

The best way to handle this in my opinion is to have one index per locale, but the syntax is clearly too complicated currently, see #307