Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Multiple indexes from Algolia to suggest the results on wordpress searc.php page #414

Open
sunnydadigs opened this issue May 6, 2024 · 3 comments

Comments

@sunnydadigs
Copy link

We have installed the plugin and managed to get the autosuggest to suggest results from multiple alogolia index without any issues using a a filter as suggested in this thread https://discourse.algolia.com/t/using-multiple-indices-on-wordpress/2617/3

its working fine for autocompletes, is there any way to make this work or any hook I can use to use multiple index for search results page on Wordpress?

@tw2113
Copy link
Member

tw2113 commented May 6, 2024

As far as I'm aware, we don't have anything like that configured or set up for the search results settings. That options page has everything go through the wp_searchable_posts index.

Curious what your needs are that are leading to this route, and if there's perhaps a different way to achieve what you need.

@sunnydadigs
Copy link
Author

sunnydadigs commented May 7, 2024

We would like to index the content of 15 sites and display the search results on the 16th site (main site). For example, if a user goes to the main site and searches with a query like "men's health," the search results should display any posts related to "men's health" from the main site, as well as posts from the other sites if available.

To accomplish this, We are considering using your algolia search plugin on each individual site to index the content from all the sites . This way, all the data will be available on algolia app as different indexes with prefixes.

All our Wordpress sites are individual installs and are hosted on the same server.

Then, on the main site we can retrieve those index when search and display the results on search template.

I managed to get it working with the autocomplete with your plugin using filter from this thread https://discourse.algolia.com/t/using-multiple-indices-on-wordpress/2617/3, i also need to make it work with the search results template.

If you can see below screenshot, I searched with the term "Barwon" and I am getting results from the other sites index perfectly as auto-suggested. those results are coming from one of my other sites.

image

But if I go ahead and click on the search button and no results are getting picked up on the search results page

image

Here is a link if you like to quickly test

@tw2113
Copy link
Member

tw2113 commented May 7, 2024

Okay, that's making a lot more sense here. For example, with our Algolia Pro premium addon, we did some similar things with version 1.3.0 but not quite.

With that release, we added the ability to push all content from a multisite network into one Algolia index, and allow for querying from all the sites against that one index.

What we don't have is that same functionality with non-multisite installs that are all separate. Same server or different ones isn't as much an issue as it's still all API driven to Algolia.

I'll hesitantly say it should be possible, but there'd need to be a lot of coverage of caveats and whatnot needing to be kept in mind. These types of details are generally manageable from one codebase that Multisite offers. Everything stays in sync and all installs use the exact same copy of the plugin, and we can control behind the scene details. This becomes a bigger out-of-our hands issue when it's one-to-many separate installs all needing to stay in sync.

I'm not sure if we're ever going to try and package the functionality up as a publicly released version of the plugins, but I can't say we wouldn't either if we got to a very confident point.

It may come down to more some documentation of things that we found needed to be done, list out caveats and the like as FAQs or "Make sure you...".

I know off the top of my head that objectID values would need to be made unique somehow. With Pro and our current MS setup, we append the site ID to the front of the object ID. For example every site starts out with the "Sample Page" which is always post ID 2. Without a filtered value somehow, post ID 2 overwrite a different one every time a given site syncs.

The other thing we had to change was the attributeForDistinct and we went with permalink instead of post ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants