title: How to dynamically change synonyms for ElasticSearch
body: <p>My synonyms are stored in a database and, when the synonyms are changed in the database, I want to update any values in the index which may be changed as a result of the synonym change.  </p>
  
  <p>There are two parts to this that I can think of.  One, figuring out which documents to re-index.  Two, figuring out how to tell ElasticSearch that the synonyms have changed.  I am struggling with the 2nd one - telling ElasticSearch that the synonyms have changed.</p>
  
  <p>A similar question has been asked - see <a href="https://stackoverflow.com/questions/7272368/change-dynamically-elasticsearch-synonyms">Change dynamically elasticsearch synonyms</a> - but from reading the answers in that issue, I have not been able to figure out what I need.</p>
  
  <p>Currently, my configuration file looks something like the following:</p>
  
  <pre><code>index :
    analysis :
      analyzer :
        myanalyzer :
          filter: [standard, mysynonymfilter]
  filter :
    mysynonymfilter :      
      type : synonym
      synonyms : synonyms.txt
      ignore_case : false
      expand : true
      format : solr
  </code></pre>
  
  <p>My idea was to do something like the following:</p>
  
  <pre><code>curl -XPUT 'http://127.0.0.1:9200/foo/_settings'  -d '
  {
      "filter" : {
          "synonym" : {
              "type" : "mysynonymfilter",
              "synonyms" : [
                  "cosmos, universe"
              ] 
          }
      }
  }
  '
  </code></pre>
  
  <p>but that doesn't seem to do what I want.  That is, the index settings do not get updated as far as I can tell.</p>
  
  <p>Is what I am trying to do possible?  And if so, any idea what I am doing wrong?</p>
  
  <p>Also, I am fairly sure I could get this to work by updating the synonym file (if I have to use a file), but that's a bit more complicated and something I'd like to avoid.</p>
  
  <p>Thanks for your help,
  Eric</p>