- Issue created by @infojunkie
- 🇦🇹Austria drunken monkey Vienna, Austria
Thanks for suggesting this new feature!
It makes sense to skip highlighting if it is not needed, and especially if it takes such a long time in your case. (I’m pretty certain this is an outlier, I don’t think highlighting will typically take up 2/3 of the search request time.)
However, if this is just about highlighting, then I’m not sure we really need this complex new functionality, since (as you have already noticed) setting the search query’s processing level to “basic” will already do exactly what you want. So maybe just a checkbox that says “Skip optional processing” (or something like that), explicitly mentioning highlighting in the description? (And no API change necessary.)Programmatically, I’m also not sure that temporarily changing the active processors from outside the Search API module will be that easy. And if it would be then the same might already be possible just using the existing hooks.
- 🇨🇦Canada infojunkie Vancouver
Thanks for taking the time to review this.
Yes, setting the processing level would address my particular use case, although I'm not sure about other users of your module.
Maybe it's worth keeping this open to see if anyone else is interested, and if not, just close it as a one-off request whose workaround is documented.
- 🇨🇦Canada phjou Vancouver 🇨🇦 🇪🇺
I think we have the same issue. @infojunkie Would it be possible to share the code you wrote for the workaround? Thank you.
- 🇨🇦Canada infojunkie Vancouver
Sure, here it is:
function custom_module_search_api_query_alter($query) { if ($query->hasTag('search_api_autocomplete')) { // Set the processing level to basic to prevent highlighting processor from working during autocomplete queries. $query->setProcessingLevel(\Drupal\search_api\Query\QueryInterface::PROCESSING_BASIC); } }