How to index with each fields its own synonym file

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:

 "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"
              }
            }
          }
        }
      }
    }
  }
}
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"
      }
    }
  }
}

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?

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