Query DSL: `query_string` - Expose QueryParser#setAutoGeneratePhraseQueries, closes #964.
This commit is contained in:
parent
e022f744ee
commit
b76f5150ee
|
@ -86,6 +86,7 @@ public class MapperQueryParser extends QueryParser {
|
|||
this.analyzer = settings.analyzer();
|
||||
setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
|
||||
setEnablePositionIncrements(settings.enablePositionIncrements());
|
||||
setAutoGeneratePhraseQueries(settings.autoGeneratePhraseQueries());
|
||||
setAllowLeadingWildcard(settings.allowLeadingWildcard());
|
||||
setLowercaseExpandedTerms(settings.lowercaseExpandedTerms());
|
||||
setPhraseSlop(settings.phraseSlop());
|
||||
|
|
|
@ -31,6 +31,7 @@ public class QueryParserSettings {
|
|||
private String defaultField;
|
||||
private float boost = 1.0f;
|
||||
private MapperQueryParser.Operator defaultOperator = QueryParser.Operator.OR;
|
||||
private boolean autoGeneratePhraseQueries = false;
|
||||
private boolean allowLeadingWildcard = true;
|
||||
private boolean lowercaseExpandedTerms = true;
|
||||
private boolean enablePositionIncrements = true;
|
||||
|
@ -73,6 +74,14 @@ public class QueryParserSettings {
|
|||
this.defaultOperator = defaultOperator;
|
||||
}
|
||||
|
||||
public boolean autoGeneratePhraseQueries() {
|
||||
return autoGeneratePhraseQueries;
|
||||
}
|
||||
|
||||
public void autoGeneratePhraseQueries(boolean autoGeneratePhraseQueries) {
|
||||
this.autoGeneratePhraseQueries = autoGeneratePhraseQueries;
|
||||
}
|
||||
|
||||
public boolean allowLeadingWildcard() {
|
||||
return allowLeadingWildcard;
|
||||
}
|
||||
|
@ -151,6 +160,7 @@ public class QueryParserSettings {
|
|||
|
||||
QueryParserSettings that = (QueryParserSettings) o;
|
||||
|
||||
if (autoGeneratePhraseQueries != that.autoGeneratePhraseQueries()) return false;
|
||||
if (allowLeadingWildcard != that.allowLeadingWildcard) return false;
|
||||
if (Float.compare(that.boost, boost) != 0) return false;
|
||||
if (enablePositionIncrements != that.enablePositionIncrements) return false;
|
||||
|
@ -173,6 +183,7 @@ public class QueryParserSettings {
|
|||
result = 31 * result + (defaultField != null ? defaultField.hashCode() : 0);
|
||||
result = 31 * result + (boost != +0.0f ? Float.floatToIntBits(boost) : 0);
|
||||
result = 31 * result + (defaultOperator != null ? defaultOperator.hashCode() : 0);
|
||||
result = 31 * result + (autoGeneratePhraseQueries ? 1 : 0);
|
||||
result = 31 * result + (allowLeadingWildcard ? 1 : 0);
|
||||
result = 31 * result + (lowercaseExpandedTerms ? 1 : 0);
|
||||
result = 31 * result + (enablePositionIncrements ? 1 : 0);
|
||||
|
|
|
@ -83,6 +83,8 @@ public class FieldQueryParser extends AbstractIndexComponent implements XContent
|
|||
qpSettings.enablePositionIncrements(parser.booleanValue());
|
||||
} else if ("allow_leading_wildcard".equals(currentFieldName) || "allowLeadingWildcard".equals(currentFieldName)) {
|
||||
qpSettings.allowLeadingWildcard(parser.booleanValue());
|
||||
} else if ("auto_generate_phrase_queries".equals(currentFieldName) || "autoGeneratePhraseQueries".equals(currentFieldName)) {
|
||||
qpSettings.autoGeneratePhraseQueries(parser.booleanValue());
|
||||
} else if ("lowercase_expanded_terms".equals(currentFieldName) || "lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||
qpSettings.lowercaseExpandedTerms(parser.booleanValue());
|
||||
} else if ("phrase_slop".equals(currentFieldName) || "phraseSlop".equals(currentFieldName)) {
|
||||
|
|
|
@ -137,6 +137,8 @@ public class QueryStringQueryParser extends AbstractIndexComponent implements XC
|
|||
qpSettings.analyzer(analysisService.analyzer(parser.text()));
|
||||
} else if ("allow_leading_wildcard".equals(currentFieldName) || "allowLeadingWildcard".equals(currentFieldName)) {
|
||||
qpSettings.allowLeadingWildcard(parser.booleanValue());
|
||||
} else if ("auto_generate_phrase_queries".equals(currentFieldName) || "autoGeneratePhraseQueries".equals(currentFieldName)) {
|
||||
qpSettings.autoGeneratePhraseQueries(parser.booleanValue());
|
||||
} else if ("lowercase_expanded_terms".equals(currentFieldName) || "lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||
qpSettings.lowercaseExpandedTerms(parser.booleanValue());
|
||||
} else if ("enable_position_increments".equals(currentFieldName) || "enablePositionIncrements".equals(currentFieldName)) {
|
||||
|
|
Loading…
Reference in New Issue