# I have got a little Problem with my synonym filter

**URL:** <https://discuss.elastic.co/t/i-have-got-a-little-problem-with-my-synonym-filter/23339>\
**Category:** Elasticsearch\
**Created:** [April 21, 2015, 9:40am UTC](https://discuss.elastic.co/t/i-have-got-a-little-problem-with-my-synonym-filter/23339 "2015-04-21T09:40:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ste\_Phan](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Ste\_Phan](https://discuss.elastic.co/u/Ste_Phan)\
**Post date:** [April 21, 2015, 9:40am UTC](https://discuss.elastic.co/t/i-have-got-a-little-problem-with-my-synonym-filter/23339/1 "2015-04-21T09:40:17Z")

</div>

_... I build a little sample of what I do._

_My Test Synonyms file is (test.syn placed into my /etc/elasticsearch  
folder):_

aaa,bbb,ccc,ddd  
www,xxx,yyy,zzz  
eee,fff,ggg,hhh =\> 111  
sss,ttt,uuu,vvv =\> 222  
rrr =\> 333,444,555

_I created an index like so:_

PUT /testindex?pretty  
{  
"settings": {  
"analysis": {  
"analyzer": {  
"myIndexAnalyzer": {  
"tokenizer": "standard",  
"filter": [  
"lowercase",  
"mySynonymsFilter"  
]  
},  
"mySearchAnalyzer": {  
"tokenizer": "standard",  
"filter": [  
"lowercase"  
]  
}  
},  
"filter": {  
"mySynonymsFilter": {  
"type": "synonym",  
"ignore\_case": true,  
"synonyms\_path": "test.syn"  
}  
}  
}  
},  
"mappings": {  
"testitem": {  
"properties": {  
"title": {  
"type": "string",  
"index\_analyzer": "myIndexAnalyzer",  
"search\_analyzer": "mySearchAnalyzer"  
}  
}  
}  
}  
}

_and added some data:_

POST /\_bulk  
{ "index": { "\_index": "testindex", "\_type": "testitem", "\_id": "1" }}  
{ "title": "aaa test daten eintrag." }  
{ "index": { "\_index": "testindex", "\_type": "testitem", "\_id": "2" }}  
{ "title": "bbb test daten eintrag." }  
{ "index": { "\_index": "testindex", "\_type": "testitem", "\_id": "3" }}  
{ "title": "eee test daten eintrag." }

_Testing the myIndexAnalyzer using_

POST /testindex/\_analyze?analyzer=myIndexAnalyzer&pretty  
{aaa test daten eintrag}

_Results to:_

{  
"tokens": [  
{  
"token": "aaa",  
"start\_offset": 1,  
"end\_offset": 4,  
"type": "SYNONYM",  
"position": 1  
},  
{  
"token": "bbb",  
"start\_offset": 1,  
"end\_offset": 4,  
"type": "SYNONYM",  
"position": 1  
},  
{  
"token": "ccc",  
"start\_offset": 1,  
"end\_offset": 4,  
"type": "SYNONYM",  
"position": 1  
},  
{  
"token": "ddd",  
"start\_offset": 1,  
"end\_offset": 4,  
"type": "SYNONYM",  
"position": 1  
},  
{  
"token": "test",  
"start\_offset": 5,  
"end\_offset": 9,  
"type": "",  
"position": 2  
}  
]  
}

_Which to me seems to be fine._

Searching this index, i expected to find Record Ids 1 and 2 if I am  
searching for "aaa", "bbb", "ccc", "ddd".

Which is my fault??

TIA  
Ste Phan

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/64e90076-f905-4490-bfe8-3b1607e5e98a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/64e90076-f905-4490-bfe8-3b1607e5e98a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ste\_Phan](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Ste\_Phan](https://discuss.elastic.co/u/Ste_Phan)\
**Post date:** [April 21, 2015, 9:45am UTC](https://discuss.elastic.co/t/i-have-got-a-little-problem-with-my-synonym-filter/23339/2 "2015-04-21T09:45:43Z")

</div>

> I forgot to figure out that if search for "aaa" I receive Record \_id = 1,

searching vor "bbb" I receive Record \_id = 2 ... nothing else.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2a74f413-bd31-4c9a-a3a0-95084cc2fc0d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2a74f413-bd31-4c9a-a3a0-95084cc2fc0d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [April 21, 2015, 9:49am UTC](https://discuss.elastic.co/t/i-have-got-a-little-problem-with-my-synonym-filter/23339/3 "2015-04-21T09:49:42Z")

</div>

What kind of query are you executing? Are you query against a specific  
field? A match query against the title field should work.

When using the analyze API, explicit state the field and not the analyzer  
for more accurate behavior of what really goes on.

Cheers,

Ivan  
On Apr 21, 2015 11:40 AM, "Ste Phan" [stephan.skusa@gmail.com](mailto:stephan.skusa@gmail.com) wrote:

> _... I build a little sample of what I do._
> 
> _My Test Synonyms file is (test.syn placed into my /etc/elasticsearch  
> folder):_
> 
> aaa,bbb,ccc,ddd  
> www,xxx,yyy,zzz  
> eee,fff,ggg,hhh =\> 111  
> sss,ttt,uuu,vvv =\> 222  
> rrr =\> 333,444,555
> 
> _I created an index like so:_
> 
> PUT /testindex?pretty  
> {  
> "settings": {  
> "analysis": {  
> "analyzer": {  
> "myIndexAnalyzer": {  
> "tokenizer": "standard",  
> "filter": [  
> "lowercase",  
> "mySynonymsFilter"  
> ]  
> },  
> "mySearchAnalyzer": {  
> "tokenizer": "standard",  
> "filter": [  
> "lowercase"  
> ]  
> }  
> },  
> "filter": {  
> "mySynonymsFilter": {  
> "type": "synonym",  
> "ignore\_case": true,  
> "synonyms\_path": "test.syn"  
> }  
> }  
> }  
> },  
> "mappings": {  
> "testitem": {  
> "properties": {  
> "title": {  
> "type": "string",  
> "index\_analyzer": "myIndexAnalyzer",  
> "search\_analyzer": "mySearchAnalyzer"  
> }  
> }  
> }  
> }  
> }
> 
> _and added some data:_
> 
> POST /\_bulk  
> { "index": { "\_index": "testindex", "\_type": "testitem", "\_id": "1" }}  
> { "title": "aaa test daten eintrag." }  
> { "index": { "\_index": "testindex", "\_type": "testitem", "\_id": "2" }}  
> { "title": "bbb test daten eintrag." }  
> { "index": { "\_index": "testindex", "\_type": "testitem", "\_id": "3" }}  
> { "title": "eee test daten eintrag." }
> 
> _Testing the myIndexAnalyzer using_
> 
> POST /testindex/\_analyze?analyzer=myIndexAnalyzer&pretty  
> {aaa test daten eintrag}
> 
> _Results to:_
> 
> {  
> "tokens": [  
> {  
> "token": "aaa",  
> "start\_offset": 1,  
> "end\_offset": 4,  
> "type": "SYNONYM",  
> "position": 1  
> },  
> {  
> "token": "bbb",  
> "start\_offset": 1,  
> "end\_offset": 4,  
> "type": "SYNONYM",  
> "position": 1  
> },  
> {  
> "token": "ccc",  
> "start\_offset": 1,  
> "end\_offset": 4,  
> "type": "SYNONYM",  
> "position": 1  
> },  
> {  
> "token": "ddd",  
> "start\_offset": 1,  
> "end\_offset": 4,  
> "type": "SYNONYM",  
> "position": 1  
> },  
> {  
> "token": "test",  
> "start\_offset": 5,  
> "end\_offset": 9,  
> "type": "",  
> "position": 2  
> }  
> ]  
> }
> 
> _Which to me seems to be fine._
> 
> Searching this index, i expected to find Record Ids 1 and 2 if I am  
> searching for "aaa", "bbb", "ccc", "ddd".
> 
> Which is my fault??
> 
> TIA  
> Ste Phan
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/64e90076-f905-4490-bfe8-3b1607e5e98a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/64e90076-f905-4490-bfe8-3b1607e5e98a%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/64e90076-f905-4490-bfe8-3b1607e5e98a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/64e90076-f905-4490-bfe8-3b1607e5e98a%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQB6A9nq1GC52sdugQx1%2BM\_pJJvdo6ti0ofQYfbOqK6P2A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQB6A9nq1GC52sdugQx1%2BM_pJJvdo6ti0ofQYfbOqK6P2A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ste\_Phan](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Ste\_Phan](https://discuss.elastic.co/u/Ste_Phan)\
**Post date:** [April 22, 2015, 1:55pm UTC](https://discuss.elastic.co/t/i-have-got-a-little-problem-with-my-synonym-filter/23339/4 "2015-04-22T13:55:11Z")

</div>

I tried multi\_match queries.

The little Example seems to work meanwhile ... don't know why?! But my  
original index has the same problem.

I am posting the synonyms file, so as the create statement.

Analyzing this via:

GET /myindex/\_analyze?field=article.authors  
{gumbel}

results to:

{  
"tokens": [  
{  
"token": "gumbel",  
"start\_offset": 1,  
"end\_offset": 7,  
"type": "",  
"position": 1  
}  
]  
}

No synonym results as I would expect. Searching for a synonym "gumble" for  
example gives no results.

I would be glad to hear from you ... TIA

Ste Phan

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0aa73333-56ce-40af-a5e5-1f7673ff60a9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0aa73333-56ce-40af-a5e5-1f7673ff60a9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ste\_Phan](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Ste\_Phan](https://discuss.elastic.co/u/Ste_Phan)\
**Post date:** [April 22, 2015, 2:57pm UTC](https://discuss.elastic.co/t/i-have-got-a-little-problem-with-my-synonym-filter/23339/5 "2015-04-22T14:57:47Z")

</div>

Ok, I found my error ... the structure of the index definition was wrong  
... sorry.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7fea8770-154c-4815-be1b-e2ed397a4944%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7fea8770-154c-4815-be1b-e2ed397a4944%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:18am UTC](https://discuss.elastic.co/t/i-have-got-a-little-problem-with-my-synonym-filter/23339/6 "2017-07-06T00:18:16Z")

</div>


