Add missing TextQueryBuilder and FuzzyQueryBuilder properties

This commit is contained in:
Igor Motov 2012-04-23 10:01:39 -04:00 committed by Shay Banon
parent 783649adc7
commit 22b2aa69d1
2 changed files with 15 additions and 0 deletions

View File

@ -40,6 +40,8 @@ public class FuzzyQueryBuilder extends BaseQueryBuilder {
private Integer prefixLength;
private Integer maxExpansions;
/**
* Constructs a new term query.
*
@ -75,6 +77,11 @@ public class FuzzyQueryBuilder extends BaseQueryBuilder {
return this;
}
public FuzzyQueryBuilder maxExpansions(int maxExpansions) {
this.maxExpansions = maxExpansions;
return this;
}
@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(FuzzyQueryParser.NAME);
@ -92,6 +99,9 @@ public class FuzzyQueryBuilder extends BaseQueryBuilder {
if (prefixLength != null) {
builder.field("prefix_length", prefixLength);
}
if (maxExpansions != null) {
builder.field("max_expansions", maxExpansions);
}
builder.endObject();
}
builder.endObject();

View File

@ -126,6 +126,11 @@ public class TextQueryBuilder extends BaseQueryBuilder {
return this;
}
public TextQueryBuilder prefixLength(int prefixLength) {
this.prefixLength = prefixLength;
return this;
}
/**
* When using fuzzy or prefix type query, the number of term expansions to use. Defaults to unbounded
* so its recommended to set it to a reasonable value for faster execution.