algoliasearch-rails icon indicating copy to clipboard operation
algoliasearch-rails copied to clipboard

Algolia with globalize gem

Open jonhue opened this issue 7 years ago • 5 comments
trafficstars

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?

jonhue avatar Dec 09 '17 09:12 jonhue

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

casiodk avatar Mar 04 '18 00:03 casiodk

+1 also interested in this

severin avatar Mar 15 '18 14:03 severin

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

jonhue avatar Mar 23 '18 16:03 jonhue

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?

redox avatar Mar 26 '18 08:03 redox

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

Spone avatar Feb 14 '19 08:02 Spone