Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch - Update similarity measure for existing index

I have an existing index for which the default ElasticSearch similarity is used for all fields. I would like to update this index and set some other type of similarity, like BM25. The query I tried is:

curl -XPOST 'http://localhost:9200/myindex/' -d '
{
   "settings":
    {
       "similarity":
        {
          "newSimilarity":
           {
            "type":"BM25"
           }
         }
     }
}'

However, this crashes with an IndexAlreadyExists exception. I have also tried

curl -XPUT 'http://localhost:9200/doc/_mapping' -d '
{
  "doc":
  {
    "properties":
     {
       "myField":
        { 
          "type":"string", 
          "term_vector":"with_positions_offsets_payloads", 
          "similarity":"BM25"
         }
      }
   }
 }

And this gives me a MergeMappingException - [Merge failed with failures {[mapper [text_content] has different similarity. Setting ignore_conflicts to true doesn't really help, it ignores the conflicts but doesn't change the mapping.

Still, I would like to know if is it possible to update the similarity measure for all fields inside this index without having to reindex the data. Any suggestions would be much appreciated.

Thanks!

like image 411
Crista23 Avatar asked Nov 03 '25 01:11

Crista23


1 Answers

No at the moment elasticsearch does not allow changing the similarity on the fly . You would have to reindex. https://github.com/elasticsearch/elasticsearch/issues/4403

like image 70
keety Avatar answered Nov 04 '25 17:11

keety



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!