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)

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 .

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.