mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-23 13:26:02 +00:00
PatternAnalyzer should lowercase wildcard queries when lowercase
is true. (#24967)
This commit is contained in:
parent
7c1211d2ed
commit
71264c6239
@ -53,4 +53,13 @@ public final class PatternAnalyzer extends Analyzer {
|
||||
}
|
||||
return new TokenStreamComponents(tokenizer, stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TokenStream normalize(String fieldName, TokenStream in) {
|
||||
TokenStream stream = in;
|
||||
if (lowercase) {
|
||||
stream = new LowerCaseFilter(stream);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.core.StopAnalyzer;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.test.ESTokenStreamTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -111,4 +112,11 @@ public class PatternAnalyzerTests extends ESTokenStreamTestCase {
|
||||
Analyzer a = new PatternAnalyzer(Pattern.compile(","), true, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
|
||||
checkRandomData(random(), a, 10000*RANDOM_MULTIPLIER);
|
||||
}
|
||||
|
||||
public void testNormalize() {
|
||||
PatternAnalyzer a = new PatternAnalyzer(Pattern.compile("\\s+"), false, null);
|
||||
assertEquals(new BytesRef("FooBar"), a.normalize("dummy", "FooBar"));
|
||||
a = new PatternAnalyzer(Pattern.compile("\\s+"), true, null);
|
||||
assertEquals(new BytesRef("foobar"), a.normalize("dummy", "FooBar"));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user