# Completion suggester make synonyms rank lower

**URL:** <https://discuss.elastic.co/t/completion-suggester-make-synonyms-rank-lower/88143>\
**Category:** Elasticsearch\
**Created:** [June 3, 2017, 1:46am UTC](https://discuss.elastic.co/t/completion-suggester-make-synonyms-rank-lower/88143 "2017-06-03T01:46:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikob](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mikob](https://discuss.elastic.co/u/mikob)\
**Post date:** [June 3, 2017, 1:46am UTC](https://discuss.elastic.co/t/completion-suggester-make-synonyms-rank-lower/88143/1 "2017-06-03T01:46:28Z")

</div>

I am using the completion suggester for typeahead functionality. I have synonyms set up for US states like so `la => louisiana`. The problem is if, for example, if I query `la` I get flooded with results for `Louisiana`, but I need the non-synonyms to rank higher as the user is more likely searching for `La Acebeda, Spain` or something else with `la` at the front. The point is I need the synonyms but they should rank lower. Shouldn't this be how it works by default anyway?

This is how my index is setup in elasticsearch 5.4.0:

```
"suggest": {
        "max_input_length": 50,
        "analyzer": "autocomplete",
        "preserve_position_increments": True,
        "type": "completion",
        "search_analyzer": "synonimize",
        "preserve_separators": True,
        "contexts": [
            {
                "name": "type",
                "type": "category",
                "path": "_type",
            },
        ]
    },

```

My settings:

```
'settings': {
        "analysis": {
            "filter": {
                "addy_synonym_filter": {
                    "type": "synonym",
                    "synonyms_path": "/usr/share/elasticsearch/data/synonyms.txt",
                },
            },
            "analyzer": {
                "autocomplete": {
                    "type": "custom",
                    "tokenizer": "lowercase",
                },
                "synonimize": {
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "addy_synonym_filter",
                    ]
                }
            }
        }
    }

```

And my search queries:

```
 'suggest': {
        'region': {
            'text': "la",
            'completion': {
                'field': 'suggest',
                'size': 15,
                "contexts": {
                    "type": "region"
                }
            },
        },
```

---

<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:** [July 1, 2017, 1:47am UTC](https://discuss.elastic.co/t/completion-suggester-make-synonyms-rank-lower/88143/2 "2017-07-01T01:47:08Z")

</div>

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