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

_analyze api does not correctly use normalizers when specified #48866

Merged
merged 3 commits into from
Nov 14, 2019
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 @@ -171,6 +171,7 @@ private static Analyzer getAnalyzer(AnalyzeAction.Request request, AnalysisRegis
if (analyzer == null) {
throw new IllegalArgumentException("failed to find normalizer under [" + request.normalizer() + "]");
}
return analyzer;
}
if (request.field() != null) {
if (indexService == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,14 @@ public void testCustomCharFilterWithParameters() throws IOException {
public void testNormalizerWithIndex() throws IOException {
AnalyzeAction.Request request = new AnalyzeAction.Request("index");
request.normalizer("my_normalizer");
request.text("ABc");
// this should be lowercased and only emit a single token
request.text("Wi-fi");
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
AnalyzeAction.Response analyze
= TransportAnalyzeAction.analyze(request, registry, mockIndexService(), maxTokenCount);
List<AnalyzeAction.AnalyzeToken> tokens = analyze.getTokens();

assertEquals(1, tokens.size());
assertEquals("abc", tokens.get(0).getTerm());
assertEquals("wi-fi", tokens.get(0).getTerm());
}

/**
Expand Down