JR3652
JR3652

Reputation: 445

Elasticsearch synonym mapping going both ways?

I have a synonym mapping in my synonyms.txt that I believe should be singularly mapping the word email to outlook.

email => outlook

When I search on the word email, I'm getting results for email and outlook, as would be expected, but when I search on the word outlook, I am getting results that have either the word outlook or email in the response.

For example, I'd do a search on Outlook and expect only responses with Outlook in the field I'm searching on, but I'm also getting results that have solely Email in the field as well.

Am I misunderstanding how this synonym mapping should be working, or is something going wrong here?

I am following the directions here: https://www.elastic.co/guide/en/elasticsearch/reference/6.2/analysis-synonym-graph-tokenfilter.html

Upvotes: 1

Views: 630

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

If you only want to apply the transformation when querying, be sure to use search_analyzer (which only applies when querying / searching) and not analyzer (which applies both when indexing and querying).

Upvotes: 3

Related Questions