# How to index with each fields its own synonym file

**URL:** <https://discuss.elastic.co/t/how-to-index-with-each-fields-its-own-synonym-file/70012>\
**Category:** Elasticsearch\
**Created:** [December 26, 2016, 2:58pm UTC](https://discuss.elastic.co/t/how-to-index-with-each-fields-its-own-synonym-file/70012 "2016-12-26T14:58:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avinasha](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@avinasha](https://discuss.elastic.co/u/avinasha)\
**Post date:** [December 26, 2016, 2:58pm UTC](https://discuss.elastic.co/t/how-to-index-with-each-fields-its-own-synonym-file/70012/1 "2016-12-26T14:58:53Z")

</div>

I have five fields on my index, and I want to associated a different synonym file to each field. I defined 5 analyzers, each analyzer with its own synonym filter. When I search in field AccountNameCleanOne - i get expected results with synonym file. But synonym files are not effective on other fields. Can someone help please.

I am pasting my settings and mapping:

```auto
 "primaryindex" : {
    "mappings" : {
      "primaryindextype280777" : {
        "index_analyzer" : "mainindexanalyzer",
        "search_analyzer" : "mainsearchanalyzer",
        "properties" : {
          "primaryindextype280777" : {
            "properties" : {
              "AccountNameCleanFive" : {
                "type" : "string",
                "analyzer" : "mainindexanalyzerfive"
              },
              "AccountNameCleanFour" : {
                "type" : "string",
                "analyzer" : "mainindexanalyzerfour"
              },
              "AccountNameCleanOne" : {
                "type" : "string",
                "analyzer" : "mainindexanalyzerone"
              },
              "AccountNameCleanThree" : {
                "type" : "string",
                "analyzer" : "mainindexanalyzerthree"
              },
              "AccountNameCleanTwo" : {
                "type" : "string",
                "analyzer" : "mainindexanalyzertwo"
              },
              "AccountNameCleanZero" : {
                "type" : "string",
                "analyzer" : "mainindexanalyzerzero"
              },
              "primaryfileID" : {
                "type" : "long"
              }
            }
          }
        }
      }
    }
  }
}

```

```auto
root@vyakar:~# curl -XGET 'localhost:9200/primaryindex/_settings?pretty'
{
  "primaryindex" : {
    "settings" : {
      "index" : {
        "creation_date" : "1482744619695",
        "analysis" : {
          "filter" : {
            "myindexsynonymtwo" : {
              "ignore_case" : "true",
              "expand" : "true",
              "type" : "synonym",
              "synonyms_path" : "resources/synonymphase2.txt"
            },
            "myindexsynonymone" : {
              "ignore_case" : "true",
              "expand" : "true",
              "type" : "synonym",
              "synonyms_path" : "resources/synonymphase1.txt"
            },
            "myindexsynonymfive" : {
              "ignore_case" : "true",
              "expand" : "true",
              "type" : "synonym",
              "synonyms_path" : "resources/synonymphase5.txt"
            },
            "myindexsynonymthree" : {
              "ignore_case" : "true",
              "expand" : "true",
              "type" : "synonym",
              "synonyms_path" : "resources/synonymphase3.txt"
            },
            "myindexsynonymfour" : {
              "ignore_case" : "true",
              "expand" : "true",
              "type" : "synonym",
              "synonyms_path" : "resources/synonymphase4.txt"
            },
            "mystopword" : {
              "type" : "stop",
              "ignore_case" : "true",
              "stopwords_path" : "resources/stopwordeng.txt"
            }
          },
          "analyzer" : {
            "mainindexanalyzerzero" : {
              "filter" : ["lowercase", "asciifolding", "unique", "mystopword"],
              "char_filter" : ["html_strip"],
              "type" : "custom",
              "tokenizer" : "whitespace"
            },
            "mainindexanalyzertwo" : {
              "filter" : ["lowercase", "asciifolding", "unique", "mystopword", "myindexsynonymtwo"],
              "char_filter" : ["html_strip"],
              "type" : "custom",
              "tokenizer" : "whitespace"
            },
            "exactindexanalyzer" : {
              "filter" : "lowercase",
              "tokenizer" : "keyword"
            },
            "mainindexanalyzerfive" : {
              "filter" : ["lowercase", "asciifolding", "unique", "mystopword", "myindexsynonymfive"],
              "char_filter" : ["html_strip"],
              "type" : "custom",
              "tokenizer" : "whitespace"
            },
            "mainindexanalyzerone" : {
              "filter" : ["lowercase", "asciifolding", "unique", "mystopword", "myindexsynonymone"],
              "char_filter" : ["html_strip"],
              "type" : "custom",
              "tokenizer" : "whitespace"
            },
            "mainsearchanalyzer" : {
              "filter" : ["lowercase", "asciifolding", "mystopword"],
              "char_filter" : ["html_strip"],
              "type" : "custom",
              "tokenizer" : "whitespace"
            },
            "mainindexanalyzer" : {
              "filter" : ["lowercase", "asciifolding", "unique", "mystopword"],
              "char_filter" : ["html_strip"],
              "type" : "custom",
              "tokenizer" : "whitespace"
            },
            "mainindexanalyzerthree" : {
              "filter" : ["lowercase", "asciifolding", "unique", "mystopword", "myindexsynonymthree"],
              "char_filter" : ["html_strip"],
              "type" : "custom",
              "tokenizer" : "whitespace"
            },
            "mainindexanalyzerfour" : {
              "filter" : ["lowercase", "asciifolding", "unique", "mystopword", "myindexsynonymfour"],
              "char_filter" : ["html_strip"],
              "type" : "custom",
              "tokenizer" : "whitespace"
            }
          }
        },
        "number_of_shards" : "5",
        "number_of_replicas" : "0",
        "version" : {
          "created" : "1070299"
        },
        "uuid" : "ZJshRvCMTkSgcvTdrwXNjw"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 26, 2016, 3:43pm UTC](https://discuss.elastic.co/t/how-to-index-with-each-fields-its-own-synonym-file/70012/2 "2016-12-26T15:43:57Z")

</div>

I would like to clarify a couple of things:

1. Which version of elasticsearch is it?

2. How do you perform the search?

3. Did you change the content of any of the synonym files after the index was created?

---

<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:** [January 23, 2017, 3:44pm UTC](https://discuss.elastic.co/t/how-to-index-with-each-fields-its-own-synonym-file/70012/3 "2017-01-23T15:44:37Z")

</div>

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