Multiple search indices per language
Is your feature request related to a problem? Please describe. I have a site with multiple languages (using WPML), and I'd like to push posts from each language into their own indices. I've tried to find a way to make it work with the existing features and filters, but it didn't work. The search would pull data from just one index, though, multiple indices are just there to separate data and have different language settings for each language.
Describe the solution you'd like
It would be nice if there was a filter similar to algolia_native_search_index_id that also exposes the current post - something akin to the "should index" filters.
Describe alternatives you've considered
I tried overriding the existing algolia_native_search_index_id filter, but that just threw an error in the plugin options, with a link to a page that I for some reason can't access (?), even though I'm an admin.
Additional context -
Good day @goranalkovic-infinum
Curious if you saw https://github.com/WebDevStudios/wp-search-with-algolia/wiki/WPML at all
Essentially instead of separating indexes by language, the wiki page guides you on including a post's locale as part of the indexed content, and then using filters at search time to have only results from the user's current chosen locale returned.
You could get just Croatian results while I just got English results.
Worth trying out, and we'll help answer questions as best able.
Hi @tw2113,
Thanks for the quick reply!
Already have a language field exposed to Algolia, so that's my backup solution.
However, the advice I got from a call with Algolia is that if possible there should be one index per language, just so you can configure query languages and other language-related settings per index for (I'm guessing) NLP and features like stop words, plural processing, etc.
Definitely understand wanting to follow their advise on such things whenever possible, and I defer to their advise whenever able to.
That said, I have to believe that providing an index for one-to-many languages, including accurately pushing the right content to each, as well as properly conditionally querying against them is going to be a decent sized lift of a project, even with what WordPress hooks and filters we have in place.
I would be surprised if someone didn't need to open tickets for "could you add a filter in this spot?" or "is there any way we could get these changes made here?" that helps accomplish those specific needs. I'm not saying we'd outright say no to everything, but we'd need to keep in mind all our other users as well, for potential changes being made.
As is, we have "$prefix_searchable_posts" hardcoded as the index used for search page integration, whether with native search template, or instantsearch js library. I think I opened a ticket to consider changing that to be customizable, but zero traction so far.
Thus, the most readymade solution at the moment is going to be the wiki page I pointed to in my first reply. Will it be 100% perfect? Probably not. Will it be something generally workable? We hope so.
That said, I have to believe that providing an index for one-to-many languages, including accurately pushing the right content to each
I haven't dug around the source of the plugin too much, so I'm probably missing some context, but I guess just having a filter that allows you to append something to the index in the process of (re-)indexing should be enough?
as well as properly conditionally querying against them is going to be a decent sized lift of a project, even with what WordPress hooks and filters we have in place.
Fair point here
I would be surprised if someone didn't need to open tickets for "could you add a filter in this spot?" or "is there any way we could get these changes made here?" that helps accomplish those specific needs. I'm not saying we'd outright say no to everything, but we'd need to keep in mind all our other users as well, for potential changes being made.
Of course, sorry if it sounded like a "please add this I need it issue", I was just curious if it was possible with everything that's currently in the plugin.
Thus, the most readymade solution at the moment is going to be the wiki page I pointed to in my first reply. Will it be 100% perfect? Probably not. Will it be something generally workable? We hope so.
I'll go with that one then, thanks!
I haven't dug around the source of the plugin too much, so I'm probably missing some context, but I guess just having a filter that allows you to append something to the index in the process of (re-)indexing should be enough?
I won't say "yes" or "no" here definitively, as we'd need to check all parts that interact to make sure we're not breaking things as much as able.
Of course, sorry if it sounded like a "please add this I need it issue", I was just curious if it was possible with everything that's currently in the plugin.
All good and definitely understood that you weren't implying that. It may be as is, but I haven't dug through the code before to have a lead of whats already able to be easily handled vs what would need changes.
That said, for the moment I'm going to leave the issue generally open, for longer term consideration.