- π΅πΉPortugal dubois
I've also run into this issue, and taking inspiration from @zviryatko's example in #10 and the type_boost processor in search_api, I've created an type-specific boost processor for Elasticsearch. I opted for this approach instead of just adding the logic to our general custom module and keeping the search_api type_boost to avoid confusing Site Builders: the processor should only show up in the 'PREPROCESS QUERY' query stage in the UI and the inoperative search_api version should be marked as discouraged. The attached patch does that.
Does this approach make sense?
- πΈπͺSweden kevinn
@dubois, your patch only works for nodes, here is an updated patch that supports all entity types.
- Status changed to Needs work
7 months ago 3:39pm 7 April 2024 - πΊπΈUnited States andyg5000 North Carolina, USA
Patch is doing what it's supposed to do π, but I'm getting the following errors notices when all of the index content entity types aren't configured. Should add a !empty check. Don't have time to update the patch today, but will try to tomorrow!
- πΊπ¦Ukraine zviryatko
@andyg5000, you may need to re-save search index configuration and re-export config. Patch altering the module's config schema and also adding new fields on search index configuration, probably some of them weren't saved, and later it tries to access property from configuration.
- Status changed to Needs review
7 months ago 2:16pm 8 April 2024 - πΊπΈUnited States andyg5000 North Carolina, USA
Hey @zviryatko
Thanks for the reply. It looks like the notices were being caused by an index with multiple entity types where some of those entity types didn't have an override (see attached).
While working on it, I realized that this patch is reusing a significant amount of the code from search_api's `TypeBoost` processor. I updated updated the working patch to extend that class and the notices are gone.
Here's what my update does:
1) Fixes the notices shown in my last post
2) Adds the default boost that I believe was missing from the original patch
3) Simplifies update by extending existing class* Note if using this, the config key is changed from the original patch, so make sure to update config.
If we don't want to extend the search_api class, I think we still need to address 1 & 2 above.
Merge request is in and patch attached here for easy review.
- πΊπ¦Ukraine zviryatko
Thanks, @andyg5000, by the way, adding diff is a good practice when updating someone's patches ;-)
- πΊπΈUnited States andyg5000 North Carolina, USA
Forgot to upload. Also forgot to upload the screenshot referenced in #15 (see attached)
Thanks!
- Merge request !50Issue #3175898 by sokru, skek, robertoperuzzo, IT-Cru, Renrhaf: Port issue... β (Open) created by andyg5000
- Open on Drupal.org βCore: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7last update
7 months ago Waiting for branch to pass - First commit to issue fork.
- π©πͺGermany yannickoo Berlin
I have added another commit to that MR to prevent an error when having entity types without multiple bundles (e.g. user or custom entities).
Warning: Undefined array key "bundle_boosts" in Drupal\elasticsearch_connector\Plugin\search_api\processor\ElasticsearchTypeBoost->preprocessSearchQuery() (line 34 of modules/contrib/elasticsearch_connector/src/Plugin/search_api/processor/ElasticsearchTypeBoost.php).