# Can we insert synonyms dynamically to index through the java Application without closing or reindexing the index if we follow stopwords inline approch (Not the file approch)

**URL:** <https://discuss.elastic.co/t/can-we-insert-synonyms-dynamically-to-index-through-the-java-application-without-closing-or-reindexing-the-index-if-we-follow-stopwords-inline-approch-not-the-file-approch/56064>\
**Category:** Elasticsearch\
**Created:** [July 21, 2016, 6:22am UTC](https://discuss.elastic.co/t/can-we-insert-synonyms-dynamically-to-index-through-the-java-application-without-closing-or-reindexing-the-index-if-we-follow-stopwords-inline-approch-not-the-file-approch/56064 "2016-07-21T06:22:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apratapi](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@apratapi](https://discuss.elastic.co/u/apratapi)\
**Post date:** [July 21, 2016, 6:22am UTC](https://discuss.elastic.co/t/can-we-insert-synonyms-dynamically-to-index-through-the-java-application-without-closing-or-reindexing-the-index-if-we-follow-stopwords-inline-approch-not-the-file-approch/56064/1 "2016-07-21T06:22:41Z")

</div>

below is the setting and mapping with the synonym analyzer and filter

"synonym\_index": {  
"settings": {  
"index": {  
"creation\_date": "1464673842267",  
"uuid": "Uo63AdrETXqF2pH\_6-vaPA",  
"number\_of\_replicas": "1",  
"analysis": {  
"filter": {  
"my\_synonym\_filter": {  
"type": "synonym",  
"synonyms": [  
"clutch,grip,grasp,clasp,cling",  
"suspension,remission,quiescence,dormancy",  
"plunger,Piston,trumpet,bung",  
"mileometer,odometer,speedometer",  
"accelerator,throttle,atom smasher,gun",  
"alternater,alturnater,allturnator,substitute,alternator",  
"haindCleener,haandCleaner,haandCleener,handCleaner",  
"anti seize,antiiseeze,antiseige,antiseize",  
"emission,edission,emmission"  
]  
}  
},  
"analyzer": {  
"my\_synonyms": {  
"filter": [  
"lowercase",  
"my\_synonym\_filter"  
],  
"tokenizer": "standard"  
}  
}  
},  
"number\_of\_shards": "5",

synonyms parameter has some list synonyms, i want to add synonyms dynamically through the java Application without closing or reindexing the index,

is there any way to achieve this. looking for soluation  
thanks for the support in advance .

---

<div class="post-metadata">

**Author:** ![a2tirb](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@a2tirb](https://discuss.elastic.co/u/a2tirb)\
**Post date:** [July 21, 2016, 1:20pm UTC](https://discuss.elastic.co/t/can-we-insert-synonyms-dynamically-to-index-through-the-java-application-without-closing-or-reindexing-the-index-if-we-follow-stopwords-inline-approch-not-the-file-approch/56064/2 "2016-07-21T13:20:52Z")

</div>

Hi,

you cannot change analyzers without closing the index before the update.

If your synonyms change frequently then maybe instead of indexing documents with synonyms you could use a dedicated search\_analyzer and change the synonyms there? That would then inject the synonyms to the search terms and you would at least not have to reindex to apply synonyms to already indexed documents . However, that too requires to close and reopen the index between updates.

---

<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:** [July 5, 2017, 10:33pm UTC](https://discuss.elastic.co/t/can-we-insert-synonyms-dynamically-to-index-through-the-java-application-without-closing-or-reindexing-the-index-if-we-follow-stopwords-inline-approch-not-the-file-approch/56064/3 "2017-07-05T22:33:42Z")

</div>


