4

I was trying to map VP to Vice President, CEO to Chief Executive Officer and so on. So that when my search keyword is VP I could see results with Vice President as well. Searchkick gem is what I used to achieve this.

I am having a person model like one below

class Person < ApplicationRecord
  searchkick merge_mappings: true,
             word_start: [:name],
             text_middle: [:title],
             synonyms:[['vp', 'vice president'],
                       ['it', 'information technology'],
                       ['ceo', 'chief executive officer'],
                       ['cto', 'chief technology officer']]
end

After re-indexing my entire data and when I check the index metadata this is what I see

"analysis": {
  "filter": {
    "searchkick_synonym": {
      "type": "synonym",
      "synonyms": [
        "vp,vicepresident",
        "it,informationtechnology",
        "ceo,chiefexecutive officer",
        "cto,chieftechnology officer"
      ]
    }
  }
}

Why is this mapped like vicepresident without space? Is this the reason why synonyms are not working in my search query? Is there any issue in the model class I created?

NB: ElasticSearch Version: 7.6.0, SearchKick Gem: 4.3.0

enter image description here

Amal Kumar S
  • 15,555
  • 19
  • 56
  • 88

1 Answers1

2

The synonyms option doesn't support multi-word synonyms. In Searchkick 4.4.0+, you can use the search_synonyms option for multi-word synonyms.

Andrew Kane
  • 3,200
  • 19
  • 40