# ES 6.4.2 - Synonym Filter Working Out Of Order

**URL:** <https://discuss.elastic.co/t/es-6-4-2-synonym-filter-working-out-of-order/190216>\
**Category:** Elasticsearch\
**Created:** [July 12, 2019, 11:00am UTC](https://discuss.elastic.co/t/es-6-4-2-synonym-filter-working-out-of-order/190216 "2019-07-12T11:00:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhinav2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhinav2/32/46615_2.png) [@abhinav2](https://discuss.elastic.co/u/abhinav2)\
**Post date:** [July 12, 2019, 11:00am UTC](https://discuss.elastic.co/t/es-6-4-2-synonym-filter-working-out-of-order/190216/1 "2019-07-12T11:00:02Z")

</div>

Version 6.4.2.

**Issue** - When you have 2 synonym filters defined, synonyms defined in second filter are working before the first set of synonyms.

**Expected** - Synonyms in the second file should work after the first set of synonyms.

**Steps to Reproduce**

**Step 1** : Create Index

PUT /es\_synonym\_bug

```
{
  "mappings": {
    "doc": {
      "_all": {
        "enabled": false
      },
      "properties": {
        "name": {
          "type": "text",
          "analyzer": "my_analyzer"
        }
      }
    }
  },
  "settings": {
    "index": {
      "number_of_shards": "1",
      "analysis": {
        "filter": {
          "first_synonym": {
            "type": "synonym",
            "synonyms": ["b => c", "f => g"]
          },
          "second_synonym": {
            "type": "synonym",
            "synonyms": ["c => d", "e => f"]
          }
        },
        "analyzer": {
          "my_analyzer": {
            "filter": [
              "first_synonym",
              "second_synonym"
            ],
            "tokenizer": "whitespace"
          }
        }
      },
      "number_of_replicas": "0"
    }
  }
}

```

**Step 2** : Run analyze query, which is working in order

GET /es\_synonym\_bug/\_analyze

```
{
  "analyzer" : "my_analyzer",
  "text" : "b"
}

```

Output

```
{
  "tokens": [
    {
      "token": "d",
      "start_offset": 0,
      "end_offset": 1,
      "type": "SYNONYM",
      "position": 0
    }
  ]
}

```

This is fine ^.

**Step 3** : Run analyze query which is working out of order. Here's the problem query -

GET /es\_synonym\_bug/\_analyze

```
{
  "analyzer" : "my_analyzer",
  "text" : "e"
}

```

Output

```
{
  "tokens": [
    {
      "token": "g",
      "start_offset": 0,
      "end_offset": 1,
      "type": "SYNONYM",
      "position": 0
    }
  ]
}

```

Expected -

```
{
  "tokens": [
    {
      "token": "f",
      "start_offset": 0,
      "end_offset": 1,
      "type": "SYNONYM",
      "position": 0
    }
  ]
}
```

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [July 12, 2019, 3:27pm UTC](https://discuss.elastic.co/t/es-6-4-2-synonym-filter-working-out-of-order/190216/2 "2019-07-12T15:27:54Z")

</div>

Hi @abhinav2,

welcome to the forum. Thanks to your great reproduction script I was able to try this out on 7.2.0. I get your expected output of

```auto
{
  "tokens": [
    {
      "token": "f",
      "start_offset": 0,
      "end_offset": 1,
      "type": "SYNONYM",
      "position": 0
    }
  ]
}

```

there, so I suspect there might have been a bugfix in the meantime. Will try to find out if this is a known issue and when this was fixed. In the meantime you might want to try it with 7.2.0 yourself and see of the order of filters works for you there.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [July 12, 2019, 4:40pm UTC](https://discuss.elastic.co/t/es-6-4-2-synonym-filter-working-out-of-order/190216/3 "2019-07-12T16:40:35Z")

</div>

fyi, I haven't found the exact change yet but the behaviour in this particular case was still as you described in 6.5 but seems to be working as expected in 6.6, so there's probably a fix somewhere around this time. Maybe you can try 6.6 and see if it solves your problem.

---

<div class="post-metadata">

**Author:** ![abhinav2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhinav2/32/46615_2.png) [@abhinav2](https://discuss.elastic.co/u/abhinav2)\
**Post date:** [July 13, 2019, 7:07pm UTC](https://discuss.elastic.co/t/es-6-4-2-synonym-filter-working-out-of-order/190216/4 "2019-07-13T19:07:32Z")

</div>

Okay, thanks for taking the time to reply. I'll try 6.6.

---

<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:** [August 10, 2019, 7:07pm UTC](https://discuss.elastic.co/t/es-6-4-2-synonym-filter-working-out-of-order/190216/5 "2019-08-10T19:07:50Z")

</div>

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