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

Allow for filtering index names used. #241

Open
tw2113 opened this issue Oct 12, 2022 · 5 comments
Open

Allow for filtering index names used. #241

tw2113 opened this issue Oct 12, 2022 · 5 comments
Labels
has PR Has changes ready for review

Comments

@tw2113
Copy link
Member

tw2113 commented Oct 12, 2022

It's possible that we may have site owners wanting to switch to using WP Search with Algolia who already have indexes available. However, their naming convention for their indexes may not match what we have generally hardcoded for index IDs.

For example, we default the InstantSearch and Searchable posts Algolia index to {$prefix_}searchable_posts

https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/includes/indices/class-algolia-searchable-posts-index.php#L387-L397

Meanwhile, for the autocomplete, it's posts_{$post_type}, terms_{$taxonomy}, and users respectively, depending on what got indexed there.

I suspect that the InstantSearch and Searchable posts index name would be most advantageous.

@tw2113
Copy link
Member Author

tw2113 commented Nov 30, 2022

Draft PR: #273

@tw2113 tw2113 added the has PR Has changes ready for review label Nov 30, 2022
@tw2113
Copy link
Member Author

tw2113 commented Nov 30, 2022

This may need a bit more consideration, as we don't have the filters in places where the prefix is being appended. We're filtering before that point

@aaronware
Copy link

I definitely +1 this. My team and I are using the plugin and are looking into indexing different environments within the same application and having the ability to filter the index names would be great for that use case. @tw2113 let me know if you need any help testing as I have a few environments I can use to test w/ some actual non-live data. On avg it's about 10 indexes for various CPTs and including Woo Products

@tw2113
Copy link
Member Author

tw2113 commented Jan 10, 2023

It won't completely cover the usecase, but I know I have a blog post in review for our WebDevStudios blog about best practices with indexes and also launches. It's not going to document how to change the complete name of indexes being used, but would cover how to handle the prefix portion.

In case not known, you're able to set all of the fields in the Settings page with a PHP constant, as documented at https://github.com/WebDevStudios/wp-search-with-algolia/wiki/Constants which could help with multiple environments.

@tw2113
Copy link
Member Author

tw2113 commented Sep 15, 2023

@aaronware worth trying this out. I just stumbled upon https://github.com/WebDevStudios/wp-search-with-algolia/blob/2.6.1/includes/class-algolia-settings.php#L338-L348 and this has been in the plugin since our initial release. It showed up as I was combing the codebase for actions/filters not documented, as part of #363

Edit: I'm getting unexpected results when using the filter. Needs further investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has PR Has changes ready for review
Projects
None yet
Development

No branches or pull requests

2 participants