Skip to content

[8.19] Use standard tokenizer in ES|QL categorize (#129642) #129688

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,22 @@ public static CategorizationAnalyzerConfig buildStandardCategorizationAnalyzer(L
.build();
}

/**
* Create a <code>categorization_analyzer</code> that will be used by the ES|QL categorize function.
* The only difference from the DSL analyzer is the tokenizer (standard instead of ml_standard).
* This means the results are slightly different from the categorize text aggregation and the ML job,
* however you can use these tokens for looking up messages in indices generated with the standard
* tokenizer. The latter is considered more important.
*/
public static CategorizationAnalyzerConfig buildStandardEsqlCategorizationAnalyzer() {

return new CategorizationAnalyzerConfig.Builder().addCharFilter("first_line_with_letters")
.setTokenizer("standard")
.addDateWordsTokenFilter()
.addLimitFilter()
.build();
}

private final String analyzer;
private final List<NameOrDefinition> charFilters;
private final NameOrDefinition tokenizer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

Expand All @@ -48,9 +47,8 @@
*/
public class CategorizeBlockHash extends BlockHash {

private static final CategorizationAnalyzerConfig ANALYZER_CONFIG = CategorizationAnalyzerConfig.buildStandardCategorizationAnalyzer(
List.of()
);
private static final CategorizationAnalyzerConfig ANALYZER_CONFIG = CategorizationAnalyzerConfig
.buildStandardEsqlCategorizationAnalyzer();
private static final int NULL_ORD = 0;

private final int channel;
Expand Down
Loading