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

Deprecate and remove camel-case nGram and edgeNGram tokenizers #50862

Merged
merged 7 commits into from
Jan 14, 2020

Conversation

cbuescher
Copy link
Member

We already deprecated and removed the camel-case versions of the nGram and edgeNGram filters
a while ago and we should do the same with the nGram and edgeNGram tokenizers.
This PR deprecates the use of these names in favour of ngram and edge_ngram in 7
and disallows usage in new indices starting with 8. The deprecation part will be
backported to 7.6.

Closes #50561

We already deprecated and removed the camel-case versions of the nGram and edgeNGram filters
a while ago and we should do the same with the nGram and edgeNGram tokenizers.
This PR deprecates the use of these names in favour of ngram and edge_ngram in 7
and disallows usage in new indices starting with 8. The deprecation part will be
backported to 7.6.

Closes elastic#50561
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Analysis)

@mayya-sharipova
Copy link
Contributor

@cbuescher Is the intent of this PR to forbid to create an index with nGram tokenizer?

If it is, the it doesn't seem to work. With your patch, I can successfully create a index with nGram tokenizer:

curl -X PUT my_index
{
   "settings":{
      "analysis":{
         "analyzer":{
            "my_analyzer":{
               "type":"custom",
               "tokenizer":"nGram"
            }
         }
      }
   },
   "mappings":{
       "properties":{
          "title": {
             "type":"text",
             "analyzer":"my_analyzer"
         }
      }
   }
}
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "my_index"
}

@mayya-sharipova mayya-sharipova self-requested a review January 10, 2020 20:21
@cbuescher
Copy link
Member Author

Is the intent of this PR to forbid to create an index with nGram tokenizer?

Yes, but the way we lazy-load analyzers and contained tokenizers doesn't allow us to catch this merely on definition of the analysis settings. The warnings/errors should be triggered however as soon as trying to use the defined analyzer through either the "_analysis" API or indexing something into the field.

@mayya-sharipova
Copy link
Contributor

@cbuescher Thanks for the clarification, it makes sense now.

{
try (IndexAnalyzers indexAnalyzers = buildAnalyzers(Version.CURRENT, "edgeNGram")) {
try (IndexAnalyzers indexAnalyzers = buildAnalyzers(
VersionUtils.randomVersionBetween(random(), Version.V_7_3_0, VersionUtils.getPreviousVersion(Version.CURRENT)),
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of Version.CURRENT should we put a specific version to make sure the test doesn't fail after v 8.0?

Copy link
Contributor

@mayya-sharipova mayya-sharipova left a comment

Choose a reason for hiding this comment

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

@cbuescher thanks, makes sense

@cbuescher
Copy link
Member Author

@mayya-sharipova thanks for reviewing, I'm going to wait for #50908 to be merged since that might change this PR and tests slightly and rework it from there. If the changes are big I might ping you again to take another look after that.

@cbuescher
Copy link
Member Author

@elasticmachine update branch

@elasticmachine
Copy link
Collaborator

merge conflict between base and head

@cbuescher
Copy link
Member Author

@mayya-sharipova with #50908 your previous example now also warns/throws right after the custom analyzer definition.

try (CommonAnalysisPlugin commonAnalysisPlugin = new CommonAnalysisPlugin()) {
Map<String, TokenizerFactory> tokenizers = createTestAnalysis(
IndexSettingsModule.newIndexSettings("index", settings), settings, commonAnalysisPlugin).tokenizer;
TokenizerFactory tokenizerFactory = tokenizers.get(deprecatedName);
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't need to pull a factory and call create to get warnings anymore, they will be emitted when createTestAnalysis is called.

Copy link
Member Author

Choose a reason for hiding this comment

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

This tests prebuild tokenizer directly though, e.g. when they are used via “_analyze” endpoint directly they wouldn’t appear in analyzers. createTestAnalysis doesn’t trigger the warning in that case if nothing refers to them from analysis settings.

@cbuescher cbuescher merged commit 9a4357a into elastic:master Jan 14, 2020
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Jan 14, 2020
…ic#50862)

We already deprecated and removed the camel-case versions of the nGram and edgeNGram
filters a while ago and we should do the same with the nGram and edgeNGram tokenizers.
This PR deprecates the use of these names in favour of ngram and edge_ngram in
7. Usage will be disallowed on new indices starting with 8 then.

Closes elastic#50561
cbuescher pushed a commit that referenced this pull request Jan 14, 2020
… (#50991)

We deprecated and removed the camel-case versions of the nGram and edgeNGram
filters a while ago and we should do the same with the nGram and edgeNGram tokenizers.
This PR deprecates the use of these names in favour of ngram and edge_ngram in
7. Usage will be disallowed on new indices starting with 8 then.
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
…ic#50862)

We already deprecated and removed the camel-case versions of the nGram and edgeNGram 
filters a while ago and we should do the same with the nGram and edgeNGram tokenizers.
This PR deprecates the use of these names in favour of ngram and edge_ngram in 7
and disallows usage in new indices starting with 8.

Closes elastic#50561
javanna added a commit to javanna/elasticsearch that referenced this pull request Sep 17, 2024
edgeNGram and NGram tokenizers and token filters were deprecated. They have not been supported in indices created from 8.0,
hence their support can entirely be removed from main.

The version related logic around the min grams can also be removed as it refers to 7.x which we no longer need to support.

Relates to elastic#50376, elastic#50862, elastic#43568
javanna added a commit that referenced this pull request Sep 18, 2024
edgeNGram and NGram tokenizers and token filters were deprecated. They have not been supported in indices created from 8.0,
hence their support can entirely be removed from main.

The version related logic around the min grams can also be removed as it refers to 7.x which we no longer need to support.

Relates to #50376, #50862, #43568
javanna added a commit to javanna/elasticsearch that referenced this pull request Sep 18, 2024
…c#113009)

edgeNGram and NGram tokenizers and token filters were deprecated. They have not been supported in indices created from 8.0,
hence their support can entirely be removed from main.

The version related logic around the min grams can also be removed as it refers to 7.x which we no longer need to support.

Relates to elastic#50376, elastic#50862, elastic#43568
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate and remove camel-case nGram and edgeNGram tokenizers
5 participants