- Issue created by @rupertj
- Status changed to Needs review
5 months ago 1:17pm 30 July 2024 - 🇬🇧United Kingdom rupertj Bristol, UK
I don't know if this is ready to merge yet - mainly as I have yet to test if I've broken existing functionality with Solr. This MR is working for me with OpenSearch though.
If you'd like to run it, you'll need to be using search_api_opensearch 3.x (which is currently still in dev) with the changes from #3454606 applied.
To explain the changes in this MR:
All the changes to existing code ate in BestBetsProcessor::preprocessSearchQuery(). I've moved getting the QueryHandler plugin instance to its own private method to clean up preprocessSearchQuery(). I've also added a new method to the QueryHandlerPluginInterface to get the search keys from the query and run any preparation on them that the search backend requires. This is because the keys for OpenSearch come back from the Query object as an array of strings, which made the existing code return early at the check on is_scalar(). The OpenSearch QueryHandler plugin therefore reassembles the array of strings back into the original search term. The Solr QueryHandler plugin just returns the search keys as-is.The new code is the OpenSearch query handler, which adds the items to boost or exclude to the query, and an event subscriber for the OpenSearch QueryParamsEvent, which alters the request made to OpenSearch to do the actual boost.
If one of the maintainers of search_api_best_bets could give this MR a quick review to confirm it's generally acceptable, I'd appreciate it. Once that's done, I'll go back, test for regressions with Solr, etc. Thanks!