Query DSL: `query_string` - Expose QueryParser#setAutoGeneratePhraseQueries, closes #964.

This commit is contained in:
kimchy 2011-05-26 10:15:35 +03:00
parent ba1bde64b9
commit c90820e03b
2 changed files with 36 additions and 0 deletions

View File

@ -45,6 +45,8 @@ public class FieldQueryBuilder extends BaseQueryBuilder {
private String analyzer;
private Boolean autoGeneratePhraseQueries;
private Boolean allowLeadingWildcard;
private Boolean lowercaseExpandedTerms;
@ -184,6 +186,19 @@ public class FieldQueryBuilder extends BaseQueryBuilder {
return this;
}
/**
* Set to true if phrase queries will be automatically generated
* when the analyzer returns more than one term from whitespace
* delimited text.
* NOTE: this behavior may not be suitable for all languages.
* <p>
* Set to false if phrase queries should only be generated when
* surrounded by double quotes.
*/
public void autoGeneratePhraseQueries(boolean autoGeneratePhraseQueries) {
this.autoGeneratePhraseQueries = autoGeneratePhraseQueries;
}
/**
* Should leading wildcards be allowed or not. Defaults to <tt>true</tt>.
*/
@ -266,6 +281,9 @@ public class FieldQueryBuilder extends BaseQueryBuilder {
if (analyzer != null) {
builder.field("analyzer", analyzer);
}
if (autoGeneratePhraseQueries != null) {
builder.field("auto_generate_phrase_queries", autoGeneratePhraseQueries);
}
if (allowLeadingWildcard != null) {
builder.field("allow_leading_wildcard", allowLeadingWildcard);
}

View File

@ -52,6 +52,8 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder {
private String analyzer;
private Boolean autoGeneratePhraseQueries;
private Boolean allowLeadingWildcard;
private Boolean lowercaseExpandedTerms;
@ -157,6 +159,19 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder {
return this;
}
/**
* Set to true if phrase queries will be automatically generated
* when the analyzer returns more than one term from whitespace
* delimited text.
* NOTE: this behavior may not be suitable for all languages.
* <p>
* Set to false if phrase queries should only be generated when
* surrounded by double quotes.
*/
public void autoGeneratePhraseQueries(boolean autoGeneratePhraseQueries) {
this.autoGeneratePhraseQueries = autoGeneratePhraseQueries;
}
/**
* Should leading wildcards be allowed or not. Defaults to <tt>true</tt>.
*/
@ -260,6 +275,9 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder {
if (analyzer != null) {
builder.field("analyzer", analyzer);
}
if (autoGeneratePhraseQueries != null) {
builder.field("auto_generate_phrase_queries", autoGeneratePhraseQueries);
}
if (allowLeadingWildcard != null) {
builder.field("allow_leading_wildcard", allowLeadingWildcard);
}