# Explicit synonym mapping fails to map any given LHS entry to RHS entry

**URL:** <https://discuss.elastic.co/t/explicit-synonym-mapping-fails-to-map-any-given-lhs-entry-to-rhs-entry/22369>\
**Category:** Elasticsearch\
**Created:** [February 25, 2015, 2:10am UTC](https://discuss.elastic.co/t/explicit-synonym-mapping-fails-to-map-any-given-lhs-entry-to-rhs-entry/22369 "2015-02-25T02:10:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyler\_H](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@Tyler\_H](https://discuss.elastic.co/u/Tyler_H)\
**Post date:** [February 25, 2015, 2:10am UTC](https://discuss.elastic.co/t/explicit-synonym-mapping-fails-to-map-any-given-lhs-entry-to-rhs-entry/22369/1 "2015-02-25T02:10:28Z")

</div>

Greetings community,

I'm hoping to get some feedback on synonym rule formatting. I'll do my best  
to explain using a pseudo example; please bear with me.

1. I have a specific use case where five documents contain the word  
_J555_, and one document contains _J5-55_.
  - both mean the same thing, but are indexed from two different  
sources over which I have no control.

  1. Users search for these documents using _J555_, _J5-55_, _J-5-55_,  
and _J-555_

How do I create a mapping that will allow each of the cases listed in #2  
result in, at the very least, the six documents referred to in #1? I  
thought this would have been the following:

_J555_, _J5-55_, _J-5-55_, _J-555 =\> J555, J5-55_

But that doesn't work as expected. We have expand=true in our synonym  
configuration. Do you have any thoughts? My main goal is simply to  
understand better how the mappings work.

Sincerely,  
Tyler

--  
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/8d8f585b-3ad2-4041-9ba3-0268999c9b24%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8d8f585b-3ad2-4041-9ba3-0268999c9b24%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Peter\_van\_der\_Weerd](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@Peter\_van\_der\_Weerd](https://discuss.elastic.co/u/Peter_van_der_Weerd)\
**Post date:** [February 25, 2015, 5:29am UTC](https://discuss.elastic.co/t/explicit-synonym-mapping-fails-to-map-any-given-lhs-entry-to-rhs-entry/22369/2 "2015-02-25T05:29:59Z")

</div>

Synonyms are working on _tokens_. So, after breaking the text into tokens.  
The '-' is normally a separator, so J5-55 gets splitted into J5 and 55.  
So, your synonym filter gets J5 and 55, and there is no rule for that.  
Could that be your problem?

If so, you can use a different tokenizer that doesn't split the '-', or use  
a charfilter that maps it to an '\_'.  
Another approach would be to use shingles,  
If you want the dash to be a separator as well, take a look at the word  
delimiter filter.

/Peter

Op woensdag 25 februari 2015 03:10:28 UTC+1 schreef Tyler H:

> Greetings community,
> 
> I'm hoping to get some feedback on synonym rule formatting. I'll do my  
> best to explain using a pseudo example; please bear with me.
> 
> 1. I have a specific use case where five documents contain the word  
> _J555_, and one document contains _J5-55_.
> - both mean the same thing, but are indexed from two different  
> sources over which I have no control.
> 
> 1. Users search for these documents using _J555_, _J5-55_, _J-5-55_,  
> and _J-555_
> 
> How do I create a mapping that will allow each of the cases listed in #2  
> result in, at the very least, the six documents referred to in #1? I  
> thought this would have been the following:
> 
> _J555_, _J5-55_, _J-5-55_, _J-555 =\> J555, J5-55_
> 
> But that doesn't work as expected. We have expand=true in our synonym  
> configuration. Do you have any thoughts? My main goal is simply to  
> understand better how the mappings work.
> 
> Sincerely,  
> Tyler

--  
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/d1e51513-e872-4962-9602-cd989ee4b0ec%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1e51513-e872-4962-9602-cd989ee4b0ec%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:30am UTC](https://discuss.elastic.co/t/explicit-synonym-mapping-fails-to-map-any-given-lhs-entry-to-rhs-entry/22369/3 "2017-07-06T00:30:21Z")

</div>

Closed on July 6, 2017, 12:30am UTC


