# Partial synonyms matching

**URL:** <https://discuss.elastic.co/t/partial-synonyms-matching/77998>\
**Category:** Elasticsearch\
**Created:** [March 9, 2017, 2:43pm UTC](https://discuss.elastic.co/t/partial-synonyms-matching/77998 "2017-03-09T14:43:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrey\_Kaprov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrey_kaprov/32/12262_2.png) [@Andrey\_Kaprov](https://discuss.elastic.co/u/Andrey_Kaprov)\
**Post date:** [March 9, 2017, 2:43pm UTC](https://discuss.elastic.co/t/partial-synonyms-matching/77998/1 "2017-03-09T14:43:43Z")

</div>

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! =)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 6, 2017, 2:44pm UTC](https://discuss.elastic.co/t/partial-synonyms-matching/77998/2 "2017-04-06T14:44:10Z")

</div>

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