4

I want to use synonyms feature of elastic search . I don't know where to keep it. Need help!

Shweta Gulati
  • 566
  • 1
  • 7
  • 17
  • How do you have installed Elasticsearch using zip or through repository(in case of Linux) ? Generally in CentOS config file location is `/etc/elasticsearch/elasticsearch.yml` – Roopendra May 30 '17 at 09:49

1 Answers1

3

You can place synonyms file in path relative to the config location.

You can have a look at Directory layout of your ES setup. It contains a config folder where you can place your synonym file and then specify relative path of that file.

For Example

    "filter" : {
                "synonym" : {
                    "type" : "synonym",
                    "synonyms_path" : "analysis/synonym.txt"
                }
            }

The above configures a synonym filter, with a path of analysis/synonym.txt (relative to the config location).

See this for more detail

EDIT:

You can also specify absolute path. As per doc

The path to the synonyms file should be specified with the synonyms_path parameter, and should be either absolute or relative to the Elasticsearch config directory.

Refer this

Richa
  • 7,419
  • 6
  • 25
  • 34
  • 1
    For production code , why should the file be kept, there must be some other location where that file can be kept coz i dont see it as a nice practice,do u have know alternative to this – Shweta Gulati May 30 '17 at 18:31
  • Do youknow where can I get a synonym file for the english language? – joseph Jun 01 '20 at 15:10