Search code examples
ruby-on-railssearchelasticsearchsearchkickboosting

Elasticsearch/ Searchkick gem - boosting fields do not return results with special characters (e.g. apostrophes)


We're using the searchkick gem in our app and have many documents with fields that contains special characters such as apostrophes, e.g. an offer with the title Valentine's Day Special.

Without boosters, a search for Valentines or Valentine's or Valentine would return the correct search results:

Activity.search "Valentines"

However when boosters for those the title field is incorporated, a search of any of the above queries will not return the Valentine's Day Special result.

Activity.search "Valentines", fields: ["title^10"]

I've been trying to troubleshoot through the Elasticsearch/ Searckick documentation but haven't found a solution yet. Anyone else encountered this problem?


Solution

  • Resolved this with a partial work match workaround:

    Offer.search("Valentine's", fields: ["name"], match: :word_middle)