# Problem with synonym token filter

**URL:** <https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801>\
**Category:** Elasticsearch\
**Created:** [February 19, 2013, 1:39pm UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801 "2013-02-19T13:39:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajesh\_Tarle](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@Rajesh\_Tarle](https://discuss.elastic.co/u/Rajesh_Tarle)\
**Post date:** [February 19, 2013, 1:39pm UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801/1 "2013-02-19T13:39:14Z")

</div>

Hi

I am newbie with elastic search.i need to use synonym filter to meet my  
requirement.

my used mapping details and synonym text file on :

> <https://gist.github.com/rajesh07/4985901>

## Requirement:

1. I need to search both direction means\*

oracle=sap and sap=oracle\*  
This it's works nicely but when using below one :

_oracle company=sap and sap =oracle company_

It doesn't work.

when i remove the space between oracle company (like oraclecompany) it's  
give me desired results.

so final conclusion from my side that synonym does not support space  
between word combination.

please help me to sorted out this problem.

Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![egaumer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/egaumer/32/2365_2.png) [@egaumer](https://discuss.elastic.co/u/egaumer)\
**Post date:** [February 19, 2013, 1:51pm UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801/2 "2013-02-19T13:51:14Z")

</div>

You need to use the proper tokenizer.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

_"The tokenizer parameter controls the tokenizers that will be used to  
tokenize the synonym, and defaults to the whitespace tokenizer."_

On Tuesday, February 19, 2013 8:39:14 AM UTC-5, raj wrote:

> Hi
> 
> I am newbie with Elasticsearch.i need to use synonym filter to meet my  
> requirement.
> 
> my used mapping details and synonym text file on :  
> [Analyzer Mapping · GitHub](https://gist.github.com/rajesh07/4985901)
> 
> ## Requirement:
> 
> 1. I need to search both direction means\*
> 
> oracle=sap and sap=oracle\*  
> This it's works nicely but when using below one :
> 
> _oracle company=sap and sap =oracle company_
> 
> It doesn't work.
> 
> when i remove the space between oracle company (like oraclecompany) it's  
> give me desired results.
> 
> so final conclusion from my side that synonym does not support space  
> between word combination.
> 
> please help me to sorted out this problem.
> 
> Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Rajesh\_Tarle](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@Rajesh\_Tarle](https://discuss.elastic.co/u/Rajesh_Tarle)\
**Post date:** [February 20, 2013, 6:45am UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801/3 "2013-02-20T06:45:43Z")

</div>

hi,

Thanks for reply,  
may you explain me. which type of tokenizer should use for this purpose.  
I have used used letter,standard and whitespacedelimeter but not got any  
solution.

Thanks

Raj

On Tuesday, February 19, 2013 7:21:14 PM UTC+5:30, egaumer wrote:

> You need to use the proper tokenizer.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/synonym-tokenfilter.html)
> 
> _"The tokenizer parameter controls the tokenizers that will be used to  
> tokenize the synonym, and defaults to the whitespace tokenizer."_
> 
> On Tuesday, February 19, 2013 8:39:14 AM UTC-5, raj wrote:
> 
> > Hi
> > 
> > I am newbie with Elasticsearch.i need to use synonym filter to meet my  
> > requirement.
> > 
> > my used mapping details and synonym text file on :  
> > [Analyzer Mapping · GitHub](https://gist.github.com/rajesh07/4985901)
> > 
> > ## Requirement:
> > 
> > 1. I need to search both direction means\*
> > 
> > oracle=sap and sap=oracle\*  
> > This it's works nicely but when using below one :
> > 
> > _oracle company=sap and sap =oracle company_
> > 
> > It doesn't work.
> > 
> > when i remove the space between oracle company (like oraclecompany) it's  
> > give me desired results.
> > 
> > so final conclusion from my side that synonym does not support space  
> > between word combination.
> > 
> > please help me to sorted out this problem.
> > 
> > Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [February 20, 2013, 3:01pm UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801/4 "2013-02-20T15:01:23Z")

</div>

Sounds like you want synonym phrases. My recommendation is to:

- Perform index time synonym expansion
- On the search side do NOT include the synonym filter in your analyzer

If this doesn't help, please provide examples showing what you believe to  
be incorrect behavior.

Thanks,  
Paul

On Tuesday, February 19, 2013 11:45:43 PM UTC-7, raj wrote:

> hi,
> 
> Thanks for reply,  
> may you explain me. which type of tokenizer should use for this purpose.  
> I have used used letter,standard and whitespacedelimeter but not got any  
> solution.
> 
> Thanks
> 
> Raj
> 
> On Tuesday, February 19, 2013 7:21:14 PM UTC+5:30, egaumer wrote:
> 
> > You need to use the proper tokenizer.
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/synonym-tokenfilter.html)
> > 
> > _"The tokenizer parameter controls the tokenizers that will be used to  
> > tokenize the synonym, and defaults to the whitespace tokenizer."_
> > 
> > On Tuesday, February 19, 2013 8:39:14 AM UTC-5, raj wrote:
> > 
> > > Hi
> > > 
> > > I am newbie with Elasticsearch.i need to use synonym filter to meet my  
> > > requirement.
> > > 
> > > my used mapping details and synonym text file on :  
> > > [Analyzer Mapping · GitHub](https://gist.github.com/rajesh07/4985901)
> > > 
> > > ## Requirement:
> > > 
> > > 1. I need to search both direction means\*
> > > 
> > > oracle=sap and sap=oracle\*  
> > > This it's works nicely but when using below one :
> > > 
> > > _oracle company=sap and sap =oracle company_
> > > 
> > > It doesn't work.
> > > 
> > > when i remove the space between oracle company (like oraclecompany) it's  
> > > give me desired results.
> > > 
> > > so final conclusion from my side that synonym does not support space  
> > > between word combination.
> > > 
> > > please help me to sorted out this problem.
> > > 
> > > Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Rajesh\_Tarle](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@Rajesh\_Tarle](https://discuss.elastic.co/u/Rajesh_Tarle)\
**Post date:** [February 27, 2013, 12:21pm UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801/5 "2013-02-27T12:21:26Z")

</div>

On Tuesday, February 19, 2013 7:09:14 PM UTC+5:30, raj wrote:

> Hi
> 
> I am newbie with Elasticsearch.i need to use synonym filter to meet my  
> requirement.
> 
> my used mapping details and synonym text file on :  
> [Analyzer Mapping · GitHub](https://gist.github.com/rajesh07/4985901)
> 
> ## Requirement:
> 
> 1. I need to search both direction means\*
> 
> oracle=sap and sap=oracle\*  
> This it's works nicely but when using below one :
> 
> _oracle company=sap and sap =oracle company_
> 
> It doesn't work.
> 
> when i remove the space between oracle company (like oraclecompany) it's  
> give me desired results.
> 
> so final conclusion from my side that synonym does not support space  
> between word combination.
> 
> please help me to sorted out this problem.
> 
> Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Rajesh\_Tarle](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@Rajesh\_Tarle](https://discuss.elastic.co/u/Rajesh_Tarle)\
**Post date:** [February 27, 2013, 12:22pm UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801/6 "2013-02-27T12:22:59Z")

</div>

On Tuesday, February 19, 2013 7:09:14 PM UTC+5:30, raj wrote:

> Hi
> 
> I am newbie with Elasticsearch.i need to use synonym filter to meet my  
> requirement.
> 
> my used mapping details and synonym text file on :  
> [Analyzer Mapping · GitHub](https://gist.github.com/rajesh07/4985901)
> 
> ## Requirement:
> 
> 1. I need to search both direction means\*
> 
> oracle=sap and sap=oracle\*  
> This it's works nicely but when using below one :
> 
> _oracle company=sap and sap =oracle company_
> 
> It doesn't work.
> 
> when i remove the space between oracle company (like oraclecompany) it's  
> give me desired results.
> 
> so final conclusion from my side that synonym does not support space  
> between word combination.
> 
> please help me to sorted out this problem.
> 
> Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Rajesh\_Tarle](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@Rajesh\_Tarle](https://discuss.elastic.co/u/Rajesh_Tarle)\
**Post date:** [February 27, 2013, 12:25pm UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801/7 "2013-02-27T12:25:52Z")

</div>

Hi ppearcy,

I have changed my Elasticsearch version to 0.20.5 it's working good and  
solve my problem.  
but now If I search using query "oracle company", i got both "sap" and  
"oracle company" reverse also working proper.  
but when I am searching using query "oracle" or "company" i got also same  
result. it's wrong.  
in my synonym file I have  
oracle company,sap

why "sap" is match to single word "oracle" or "company"?

please suggest.

Thanks  
Rajesh

On Tuesday, February 19, 2013 7:09:14 PM UTC+5:30, raj wrote:

> Hi
> 
> I am newbie with Elasticsearch.i need to use synonym filter to meet my  
> requirement.
> 
> my used mapping details and synonym text file on :  
> [Analyzer Mapping · GitHub](https://gist.github.com/rajesh07/4985901)
> 
> ## Requirement:
> 
> 1. I need to search both direction means\*
> 
> oracle=sap and sap=oracle\*  
> This it's works nicely but when using below one :
> 
> _oracle company=sap and sap =oracle company_
> 
> It doesn't work.
> 
> when i remove the space between oracle company (like oraclecompany) it's  
> give me desired results.
> 
> so final conclusion from my side that synonym does not support space  
> between word combination.
> 
> please help me to sorted out this problem.
> 
> Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [February 27, 2013, 3:35pm UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801/8 "2013-02-27T15:35:06Z")

</div>

What changes have you made to the original mapping? I noticed a few issues,  
but you must have changed it after you originally posted if you got it to  
work somewhat.

Your synonym filter is being applied to the analyzed tokens of the stream.  
Try using the analyze API on the text using the analyzer used to index it.

--  
Ivan

On Wed, Feb 27, 2013 at 4:25 AM, raj [rajesh.elasticsearch@gmail.com](mailto:rajesh.elasticsearch@gmail.com) wrote:

> Hi ppearcy,
> 
> I have changed my Elasticsearch version to 0.20.5 it's working good and  
> solve my problem.  
> but now If I search using query "oracle company", i got both "sap" and  
> "oracle company" reverse also working proper.  
> but when I am searching using query "oracle" or "company" i got also same  
> result. it's wrong.  
> in my synonym file I have  
> oracle company,sap
> 
> why "sap" is match to single word "oracle" or "company"?
> 
> please suggest.
> 
> Thanks  
> Rajesh
> 
> On Tuesday, February 19, 2013 7:09:14 PM UTC+5:30, raj wrote:
> 
> > Hi
> > 
> > I am newbie with Elasticsearch.i need to use synonym filter to meet my  
> > requirement.
> > 
> > my used mapping details and synonym text file on :  
> > [https://gist.github.com/\*\*rajesh07/4985901](https://gist.github.com/**rajesh07/4985901)[https://gist.github.com/rajesh07/4985901](https://gist.github.com/rajesh07/4985901)
> > 
> > ## Requirement:
> > 
> > 1. I need to search both direction means\*
> > 
> > oracle=sap and sap=oracle\*  
> > This it's works nicely but when using below one :
> > 
> > _oracle company=sap and sap =oracle company_
> > 
> > It doesn't work.
> > 
> > when i remove the space between oracle company (like oraclecompany) it's  
> > give me desired results.
> > 
> > so final conclusion from my side that synonym does not support space  
> > between word combination.
> > 
> > please help me to sorted out this problem.
> > 
> > Thanks
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:49am UTC](https://discuss.elastic.co/t/problem-with-synonym-token-filter/10801/9 "2017-07-06T02:49:17Z")

</div>


