Synonym analyzer not working
<p>Here are my settings:</p>

<pre><code>{
"countries": {
"aliases": {},
"mappings": {
  "country": {
    "properties": {
      "countryName": {
        "type": "string"
      }
    }
  }
},
"settings": {
  "index": {
    "creation_date": "1472140045116",
    "analysis": {
      "filter": {
        "synonym": {
          "ignore_case": "true",
          "type": "synonym",
          "synonyms_path": "synonym.txt"
        }
      },
      "analyzer": {
        "synonym": {
          "filter": [
            "synonym"
          ],
          "tokenizer": "whitespace"
        }
      }
    },
    "number_of_shards": "5",
    "number_of_replicas": "1",
    "uuid": "7-fKyD9aR2eG3BwUNdadXA",
    "version": {
      "created": "2030599"
    }
  }
},
"warmers": {}
}
}
</code></pre>

<p>My <code>synonym.txt</code> file is in the <code>config</code> folder inside the main <code>elasticsearch</code> folder.</p>

<p>Here is my query:</p>

<pre><code>query: {
    query_string: {
        fields: ["countryName"],
        default_operator: "AND",
        query: searchInput,
        analyzer: "synonym"
        }
     }
</code></pre>

<p>The words in <code>synonym.txt</code> are: <strong>us, u.s., united states</strong>.</p>

<p>So this doesn't work. What's interesting is that search works as normal, <em>except</em> for when I enter any of the words in the <code>synonym.txt</code> file. So for example, when I usually type in <strong>us</strong> into the search, I would get results. With this analyzer, <strong>us</strong> doesn't give me anything.</p>

<p>I've done <code>close</code> and <code>open</code> to my ES server, and still it doesn't work.</p>

<p><strong>EDIT</strong></p>

<p>An example of a <code>document</code>:</p>

<pre><code>{
    "_index": "countries",
    "_type": "country",
    "_id": "57aabeb80057405968de152b",
    "_score": 1,
    "_source": {
      "countryName": "United States"
    }
</code></pre>

<p>Example of <code>searchInput</code> (this is coming from the front-end):</p>

<p><code>united states</code></p>

<p><strong>EDIT #2</strong>:</p>

<p>Here is my updated index config file:</p>

<pre><code>{
"countries": {
    "aliases": {},
    "mappings": {},
    "settings": {
        "index": {
            "number_of_shards": "5",
            "creation_date": "1472219634083",
            "analysis": {
                "filter": {
                    "synonym": {
                        "ignore_case": "true",
                        "type": "synonym",
                        "synonyms_path": "synonym.txt"
                    }
                },
                "analyzer": {
                    "synonym": {
                        "filter": [
                            "synonym"
                        ],
                        "tokenizer": "whitespace"
                    }
                }
            },
            "country": {
                "properties": {
                    "countryName": {
                        "type": "string",
                        "analyzer": "synonym"
                    },
                    "number_of_replicas": "1",
                    "uuid": "50ZwpIVFTqeD_rJxlmd59Q",
                    "version": {
                        "created": "2030599"
                    }
                }
            },
            "warmers": {}
        }
    }
}
}
</code></pre>

<p>When I try adding documents, and doing a search on said documents, the <code>synonym</code> analyzer does not work for me.</p>

<p><strong>EDIT #3</strong></p>

<p>Here are 2 documents in the index:</p>

<pre><code>{
"took": 3,
"timed_out": false,
"_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
},
"hits": {
    "total": 2,
    "max_score": 1,
    "hits": [{
        "_index": "stocks",
        "_type": "stock",
        "_id": "2",
        "_score": 1,
        "_source": {
            "countryName": "United States"
        }
    }, {
        "_index": "stocks",
        "_type": "stock",
        "_id": "1",
        "_score": 1,
        "_source": {
            "countryName": "Canada"
        }
    }]
}
}
</code></pre>