We have just upgraded from ES 1.7 to 5.4.1 and were having some troubles changing the default similarity. It seems as though the Similarity property on the CreateIndexRequest object is ignored. We were doing the following:
var createIndexRequest = new CreateIndexRequest(newIndexName)
{
Mappings = mappings,
Settings = settings,
Similarity = new Similarities(new Dictionary<string, ISimilarity> { {"default", new MySimilarity()} })
};
Where we have MySimilarity defined as:
public class MySimilarity : CustomSimilarity
{
public MySimilarity()
: base("my_similarity")
{
}
}
This seemed to create a request that had the following structure:
{
"settings": {
...
},
"mappings": {
..
},
"similarity": {
"default": {
"type": "my_similarity"
}
}
}
According to https://www.elastic.co/guide/en/elasticsearch/reference/5.x/index-modules-similarity.html that is incorrect and the similarity block should come under settings and then index. Hence it didn't seem to have any effect.
We have managed to get it working using a custom setting like this:
settings.Add("index.similarity.default.type", "my_similarity");
Is this a bug or am I misunderstanding something/doing it wrong?