Vadim Selyakov
Vadim Selyakov

Reputation: 97

How to search by part of a synonym

I have products index with mapping

"synonym" : {
    "type" : "synonym",
    "synonyms" : [
        "netbook => laptop"
    ]
}

I want to search my products by query "lapt*" or "netb*"

Upvotes: 0

Views: 158

Answers (1)

Val
Val

Reputation: 217304

If searching by lapt* works but not netb* then you need to change your synonyms filter to this (i.e. replace => by a comma):

"synonym" : {
    "type" : "synonym",
    "synonyms" : [
        "netbook, laptop"
    ]
}

Using => replaces netbook by laptop and hence only the latter is indexed. Using a comma, will index both netbook and laptop and allow you to search for prefixes with both netb* and lapt*

Upvotes: 2

Related Questions