How to implement elasticsearch custom similarity plugin? How to implement elasticsearch custom similarity plugin? elasticsearch elasticsearch

How to implement elasticsearch custom similarity plugin?


The link that your posted https://github.com/tlrx/elasticsearch-custom-similarity-provider is for older version of elasticsearch.

Based on the elasticsearch taste plugin https://github.com/codelibs/elasticsearch-taste, I made a simple custom similarity plugin for version 2.1.1 with detailed explanations of all the steps https://github.com/stefansavev/elasticsearch-custom-similarity-example. I kept it simple to only three java files and one config file. I hope you find it useful.


The json that you posted is the one that creates an index, using the create index api. In the same request you can provide settings, mappings and so on for that index. Among the settings, you can register a custom similarity.

Once you created the index you need to actually index documents into it using the index api.

Also, since 0.90 you can also configure a custom similarity per field through the mappings.