Implement term fields
This commit is contained in:
parent
e1bd57c837
commit
6dfc10859f
@ -69,6 +69,7 @@ versions:
|
||||
# Should be at least one field!
|
||||
defaultFields: String[]
|
||||
pointsConfig: PointConfig[]
|
||||
termFields: String[]
|
||||
PointConfig:
|
||||
data:
|
||||
field: String
|
||||
|
@ -0,0 +1,12 @@
|
||||
package it.cavallium.dbengine.client.query;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.core.KeywordTokenizer;
|
||||
|
||||
public class NoOpAnalyzer extends Analyzer {
|
||||
|
||||
@Override
|
||||
protected TokenStreamComponents createComponents(String fieldName) {
|
||||
return new TokenStreamComponents(new KeywordTokenizer());
|
||||
}
|
||||
}
|
@ -46,8 +46,20 @@ import it.cavallium.dbengine.client.query.current.data.WildcardQuery;
|
||||
import it.cavallium.dbengine.lucene.RandomSortField;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.LowerCaseFilter;
|
||||
import org.apache.lucene.analysis.StopFilter;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.Tokenizer;
|
||||
import org.apache.lucene.analysis.core.KeywordTokenizer;
|
||||
import org.apache.lucene.analysis.en.EnglishPossessiveFilter;
|
||||
import org.apache.lucene.analysis.en.PorterStemFilter;
|
||||
import org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper;
|
||||
import org.apache.lucene.analysis.miscellaneous.SetKeywordMarkerFilter;
|
||||
import org.apache.lucene.analysis.standard.StandardTokenizer;
|
||||
import org.apache.lucene.document.DoublePoint;
|
||||
import org.apache.lucene.document.FloatPoint;
|
||||
import org.apache.lucene.document.IntPoint;
|
||||
@ -78,7 +90,16 @@ public class QueryParser {
|
||||
switch (query.getBasicType$()) {
|
||||
case StandardQuery:
|
||||
var standardQuery = (it.cavallium.dbengine.client.query.current.data.StandardQuery) query;
|
||||
|
||||
// Fix the analyzer
|
||||
Map<String, Analyzer> customAnalyzers = standardQuery
|
||||
.termFields()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Function.identity(), term -> new NoOpAnalyzer()));
|
||||
analyzer = new PerFieldAnalyzerWrapper(analyzer, customAnalyzers);
|
||||
|
||||
var standardQueryParser = new StandardQueryParser(analyzer);
|
||||
|
||||
standardQueryParser.setPointsConfigMap(standardQuery
|
||||
.pointsConfig()
|
||||
.stream()
|
||||
|
Loading…
Reference in New Issue
Block a user