Type-specific boosting is being ignored completely with elasticsearch_connector

Created on 18 June 2018, over 6 years ago
Updated 6 August 2024, 3 months ago

We are attempting to use the "Type-specific boosting" feature of Search API in combination with elasticsearch_connector, and it turns out that this is not working at all. I'm not even sure if it was ever implemented in the code.

We can change the weights from anything from 0.0 to 21.0, then reindex all of our data after clearing everything out, and the scores/relevance that comes back always remains the EXACT same value, regardless of what we set those values to.

This is a fairly big issue on a large site we are about to launch, as we really need a way to have certain content types almost always appear higher up in search, in general, of course.

πŸ› Bug report
Status

Needs review

Version

7.0

Component

Elasticsearch Connector

Created by

πŸ‡ΊπŸ‡ΈUnited States brettboylen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡΅πŸ‡Ή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
  • πŸ‡ΊπŸ‡Έ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
  • πŸ‡ΊπŸ‡Έ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!

  • Open on Drupal.org β†’
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last 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).

Production build 0.71.5 2024