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
}
]
}