use of org.apache.lucene.queryparser.flexible.standard.config.FuzzyConfig in project lucene-solr by apache.
the class StandardQueryParser method setFuzzyPrefixLength.
/**
* Set the prefix length for fuzzy queries. Default is 0.
*
* @param fuzzyPrefixLength
* The fuzzyPrefixLength to set.
*/
@Override
public void setFuzzyPrefixLength(int fuzzyPrefixLength) {
QueryConfigHandler config = getQueryConfigHandler();
FuzzyConfig fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG);
if (fuzzyConfig == null) {
fuzzyConfig = new FuzzyConfig();
config.set(ConfigurationKeys.FUZZY_CONFIG, fuzzyConfig);
}
fuzzyConfig.setPrefixLength(fuzzyPrefixLength);
}
use of org.apache.lucene.queryparser.flexible.standard.config.FuzzyConfig in project lucene-solr by apache.
the class StandardQueryParser method setFuzzyMinSim.
/**
* Set the minimum similarity for fuzzy queries. Default is defined on
* {@link FuzzyQuery#defaultMinSimilarity}.
*/
@Override
public void setFuzzyMinSim(float fuzzyMinSim) {
QueryConfigHandler config = getQueryConfigHandler();
FuzzyConfig fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG);
if (fuzzyConfig == null) {
fuzzyConfig = new FuzzyConfig();
config.set(ConfigurationKeys.FUZZY_CONFIG, fuzzyConfig);
}
fuzzyConfig.setMinSimilarity(fuzzyMinSim);
}
use of org.apache.lucene.queryparser.flexible.standard.config.FuzzyConfig in project lucene-solr by apache.
the class FuzzyQueryNodeProcessor method preProcessNode.
@Override
protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {
if (node instanceof FuzzyQueryNode) {
FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) node;
QueryConfigHandler config = getQueryConfigHandler();
Analyzer analyzer = getQueryConfigHandler().get(ConfigurationKeys.ANALYZER);
if (analyzer != null) {
// because we call utf8ToString, this will only work with the default TermToBytesRefAttribute
String text = fuzzyNode.getTextAsString();
text = analyzer.normalize(fuzzyNode.getFieldAsString(), text).utf8ToString();
fuzzyNode.setText(text);
}
FuzzyConfig fuzzyConfig = null;
if ((fuzzyConfig = config.get(ConfigurationKeys.FUZZY_CONFIG)) != null) {
fuzzyNode.setPrefixLength(fuzzyConfig.getPrefixLength());
if (fuzzyNode.getSimilarity() < 0) {
fuzzyNode.setSimilarity(fuzzyConfig.getMinSimilarity());
}
} else if (fuzzyNode.getSimilarity() < 0) {
throw new IllegalArgumentException("No FUZZY_CONFIG set in the config");
}
}
return node;
}
Aggregations