Partial synonyms matching

Hello, dear friends!

I'm working now with ES 5 and I wanted to implement the Partial synonyms matching

I.e

I have a synonym mapping:
name_1, name_one, first_name, 1name => your_first_name

My documents has a field "name" that contains value "name". There is my index settings:

"analysis": {
  "filter": {
    "synonym": {
      "type": "synonym",
      "synonyms_path": "analysis/synonym.txt"
    },
    "edge_nGram_filter": {
      "type": "edge_ngram",
      "min_gram": 1,
      "max_gram": 20,
      "token_chars": [
        "letter",
        "digit",
        "punctuation",
        "symbol"
      ]
    }
  },
  "analyzer": {
    "edge_nGram_analyzer": {
      "type": "custom",
      "tokenizer": "whitespace",
      "filter": [
        "lowercase",
        "asciifolding",
        "edge_nGram_filter"
      ]
    },
    "synonyms_whitespace_analyzer": {
      "type": "custom",
      "tokenizer": "whitespace",
      "filter": [
        "lowercase",
        "asciifolding",
        "synonym"
      ]
    }
  }
}

And document mapping:

{
"name": {
"type": "text",
"store": true,
"analyzer": "edge_nGram_analyzer",
"search_analyzer": "synonyms_whitespace_analyzer"
}
}

when I query for one of the synonyms:

POST /my_index/my_documents/_search
"Body":
{
"size": 1000,
"highlight": {
"pre_tags": [
""
],
"post_tags": [
""
],
"fields": {
"suggestions": {}
}
},
"query": {
"match": {
"name": {
"query": "1na", //part of one of the synonyms (1name)
"operator": "and"
}
}
}
}

I expect to see the main token (your_first_name) in hughtlight section.
I want to implement this with synonyms on different languages.

Sorry for bad language, I hope you got the main idea.
Best regards! =)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.