Query DSL: `query_string` - Expose QueryParser#setAutoGeneratePhraseQueries, closes #964.
This commit is contained in:
parent
ba1bde64b9
commit
c90820e03b
|
@ -45,6 +45,8 @@ public class FieldQueryBuilder extends BaseQueryBuilder {
|
||||||
|
|
||||||
private String analyzer;
|
private String analyzer;
|
||||||
|
|
||||||
|
private Boolean autoGeneratePhraseQueries;
|
||||||
|
|
||||||
private Boolean allowLeadingWildcard;
|
private Boolean allowLeadingWildcard;
|
||||||
|
|
||||||
private Boolean lowercaseExpandedTerms;
|
private Boolean lowercaseExpandedTerms;
|
||||||
|
@ -184,6 +186,19 @@ public class FieldQueryBuilder extends BaseQueryBuilder {
|
||||||
return this;
|
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>.
|
* Should leading wildcards be allowed or not. Defaults to <tt>true</tt>.
|
||||||
*/
|
*/
|
||||||
|
@ -266,6 +281,9 @@ public class FieldQueryBuilder extends BaseQueryBuilder {
|
||||||
if (analyzer != null) {
|
if (analyzer != null) {
|
||||||
builder.field("analyzer", analyzer);
|
builder.field("analyzer", analyzer);
|
||||||
}
|
}
|
||||||
|
if (autoGeneratePhraseQueries != null) {
|
||||||
|
builder.field("auto_generate_phrase_queries", autoGeneratePhraseQueries);
|
||||||
|
}
|
||||||
if (allowLeadingWildcard != null) {
|
if (allowLeadingWildcard != null) {
|
||||||
builder.field("allow_leading_wildcard", allowLeadingWildcard);
|
builder.field("allow_leading_wildcard", allowLeadingWildcard);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder {
|
||||||
|
|
||||||
private String analyzer;
|
private String analyzer;
|
||||||
|
|
||||||
|
private Boolean autoGeneratePhraseQueries;
|
||||||
|
|
||||||
private Boolean allowLeadingWildcard;
|
private Boolean allowLeadingWildcard;
|
||||||
|
|
||||||
private Boolean lowercaseExpandedTerms;
|
private Boolean lowercaseExpandedTerms;
|
||||||
|
@ -157,6 +159,19 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder {
|
||||||
return this;
|
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>.
|
* Should leading wildcards be allowed or not. Defaults to <tt>true</tt>.
|
||||||
*/
|
*/
|
||||||
|
@ -260,6 +275,9 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder {
|
||||||
if (analyzer != null) {
|
if (analyzer != null) {
|
||||||
builder.field("analyzer", analyzer);
|
builder.field("analyzer", analyzer);
|
||||||
}
|
}
|
||||||
|
if (autoGeneratePhraseQueries != null) {
|
||||||
|
builder.field("auto_generate_phrase_queries", autoGeneratePhraseQueries);
|
||||||
|
}
|
||||||
if (allowLeadingWildcard != null) {
|
if (allowLeadingWildcard != null) {
|
||||||
builder.field("allow_leading_wildcard", allowLeadingWildcard);
|
builder.field("allow_leading_wildcard", allowLeadingWildcard);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue