# Specifying analyzer for the synonym parser

**URL:** <https://discuss.elastic.co/t/specifying-analyzer-for-the-synonym-parser/132156>\
**Category:** Elasticsearch\
**Created:** [May 16, 2018, 2:48pm UTC](https://discuss.elastic.co/t/specifying-analyzer-for-the-synonym-parser/132156 "2018-05-16T14:48:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aclowkey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclowkey/32/51020_2.png) [@aclowkey](https://discuss.elastic.co/u/aclowkey)\
**Post date:** [May 16, 2018, 2:48pm UTC](https://discuss.elastic.co/t/specifying-analyzer-for-the-synonym-parser/132156/1 "2018-05-16T14:48:49Z")

</div>

Hi,

I'm designing an analysis chain which has shingle and synonym graph filter, and other lowercase, stemmer,etc.

The purpose is to map tokens to custom dictionary and support overlapping tokens.  
For example.  
Dictionary:

> red =\> color\_1  
> red shift =\> company\_1

Query:

> Red shift

Desired analysis:

> [color\_1,company\_1]

Now the issue is, when Elasticsearch parses the synonym list, it uses the same analyzer to analyze the terms in the dictionary . [Link to source:](https://github.com/elastic/elasticsearch/blob/99f88f15c5febbca2d13b5b5fda27b844153bf1a/server/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java#L104)

The shingle token filter produces n-grams which have position increment 0. [Link to source](https://github.com/apache/lucene-solr/blob/e2521b2a8baabdaf43b92192588f51e042d21e97/lucene/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilter.java#L339)

The SynonymMap throws exceptions on for tokens which have increment value != 1. [Link to source](https://github.com/apache/lucene-solr/blob/4e5597716a100c70ac0066fe70f5b096806d5679/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java#L324)

I tried to workaround this issue by Lucene code. and I did this by using a different analyzer to parse the synonyms.

---

<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:** [June 13, 2018, 2:48pm UTC](https://discuss.elastic.co/t/specifying-analyzer-for-the-synonym-parser/132156/2 "2018-06-13T14:48:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
