Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix similarity upgrade when "default" similarity is overridden #23163

Merged
merged 2 commits into from
Feb 14, 2017
Merged

Fix similarity upgrade when "default" similarity is overridden #23163

merged 2 commits into from
Feb 14, 2017

Conversation

jimczi
Copy link
Contributor

@jimczi jimczi commented Feb 14, 2017

Discovered in elastic/elasticsearch-migration#103

In 5.x we renamed the "default" similarity to "classic". Though in 2.x it is possible to override
the "default" similarity and to define a new type for "default":

PUT t
{
 "settings": {
   "index": {
     "similarity": {
       "default": {
         "type": "BM25"
       }
     }
   }
 },
 "mappings": {
   "t": {
     "properties": {
       "title": {
         "type": "text",
         "similarity": "default"
       }
     }
   }
 }
}

When we upgrade this index to 5.x the similarity name for "text" is renamed to "classic" even though the "default" similarity type has been overriden.
This change fixes this upgrade bug and adds a test for it.

In 5.x we renamed the "default" similarity in "classic". Though in 2.x it is possible to override
 the "default" similarity and to define a new type for "default":
 ````
 PUT t
{
  "settings": {
    "index": {
      "similarity": {
        "default": {
          "type": "BM25"
        }
      }
    }
  },
  "mappings": {
    "t": {
      "properties": {
        "title": {
          "type": "text",
          "similarity": "default"
        }
      }
    }
  }
}
````

When we upgrade this index to 5.x the similarity name for "text" is renamed to "classic" even though the "default" similarity type has been overriden.
This change fixes this upgrade bug and adds a test for it.
Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor suggestion on the test.

.endObject().string();
Settings settings = Settings.builder()
.put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_2_0))
.put("index.similarity.default.type", "BM25")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use something other than BM25 for the test, since that is the new default?

@jimczi jimczi merged commit ee4aaaa into elastic:5.x Feb 14, 2017
@jimczi jimczi deleted the upgrade_default_similarity_5x branch February 14, 2017 18:32
jimczi added a commit that referenced this pull request Feb 14, 2017
In 5.x we renamed the "default" similarity in "classic". Though in 2.x it is possible to override
 the "default" similarity and to define a new type for "default":
 ````
 PUT t
{
  "settings": {
    "index": {
      "similarity": {
        "default": {
          "type": "BM25"
        }
      }
    }
  },
  "mappings": {
    "t": {
      "properties": {
        "title": {
          "type": "text",
          "similarity": "default"
        }
      }
    }
  }
}
````

When we upgrade this index to 5.x the similarity name for "text" is renamed to "classic" even though the "default" similarity type has been overriden.
This change fixes this upgrade bug and adds a test for it.
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Similarities labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories >upgrade v5.3.0 v5.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants