rename max_num_terms to max_query_terms so its similar to mlt

This commit is contained in:
kimchy 2010-04-05 00:32:08 +03:00
parent 6480daff78
commit 341f6d3963
7 changed files with 20 additions and 20 deletions

View File

@ -36,7 +36,7 @@ public class FuzzyLikeThisFieldJsonQueryBuilder extends BaseJsonQueryBuilder {
private String likeText = null;
private Float minSimilarity;
private Integer prefixLength;
private Integer maxNumTerms;
private Integer maxQueryTerms;
private Boolean ignoreTF;
/**
@ -66,8 +66,8 @@ public class FuzzyLikeThisFieldJsonQueryBuilder extends BaseJsonQueryBuilder {
return this;
}
public FuzzyLikeThisFieldJsonQueryBuilder maxNumTerms(int maxNumTerms) {
this.maxNumTerms = maxNumTerms;
public FuzzyLikeThisFieldJsonQueryBuilder maxQueryTerms(int maxQueryTerms) {
this.maxQueryTerms = maxQueryTerms;
return this;
}
@ -88,8 +88,8 @@ public class FuzzyLikeThisFieldJsonQueryBuilder extends BaseJsonQueryBuilder {
throw new QueryBuilderException("fuzzyLikeThis requires 'likeText' to be provided");
}
builder.field("like_text", likeText);
if (maxNumTerms != null) {
builder.field("max_num_terms", maxNumTerms);
if (maxQueryTerms != null) {
builder.field("max_query_terms", maxQueryTerms);
}
if (minSimilarity != null) {
builder.field("min_similarity", minSimilarity);

View File

@ -65,7 +65,7 @@ public class FuzzyLikeThisFieldJsonQueryParser extends AbstractIndexComponent im
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
JsonParser jp = parseContext.jp();
int maxNumTerms = 100;
int maxNumTerms = 25;
float boost = 1.0f;
String likeText = null;
float minSimilarity = 0.5f;
@ -88,7 +88,7 @@ public class FuzzyLikeThisFieldJsonQueryParser extends AbstractIndexComponent im
} else if (token == JsonToken.VALUE_STRING) {
if ("like_text".equals(currentFieldName)) {
likeText = jp.getText();
} else if ("max_num_terms".equals(currentFieldName)) {
} else if ("max_query_terms".equals(currentFieldName)) {
maxNumTerms = Integer.parseInt(jp.getText());
} else if ("boost".equals(currentFieldName)) {
boost = Float.parseFloat(jp.getText());
@ -96,7 +96,7 @@ public class FuzzyLikeThisFieldJsonQueryParser extends AbstractIndexComponent im
ignoreTF = Booleans.parseBoolean(jp.getText(), false);
}
} else if (token == JsonToken.VALUE_NUMBER_INT) {
if ("max_num_terms".equals(currentFieldName)) {
if ("max_query_terms".equals(currentFieldName)) {
maxNumTerms = jp.getIntValue();
} else if ("boost".equals(currentFieldName)) {
boost = jp.getIntValue();

View File

@ -36,7 +36,7 @@ public class FuzzyLikeThisJsonQueryBuilder extends BaseJsonQueryBuilder {
private String likeText = null;
private Float minSimilarity;
private Integer prefixLength;
private Integer maxNumTerms;
private Integer maxQueryTerms;
private Boolean ignoreTF;
/**
@ -73,8 +73,8 @@ public class FuzzyLikeThisJsonQueryBuilder extends BaseJsonQueryBuilder {
return this;
}
public FuzzyLikeThisJsonQueryBuilder maxNumTerms(int maxNumTerms) {
this.maxNumTerms = maxNumTerms;
public FuzzyLikeThisJsonQueryBuilder maxQueryTerms(int maxQueryTerms) {
this.maxQueryTerms = maxQueryTerms;
return this;
}
@ -101,8 +101,8 @@ public class FuzzyLikeThisJsonQueryBuilder extends BaseJsonQueryBuilder {
throw new QueryBuilderException("fuzzyLikeThis requires 'likeText' to be provided");
}
builder.field("like_text", likeText);
if (maxNumTerms != null) {
builder.field("max_num_terms", maxNumTerms);
if (maxQueryTerms != null) {
builder.field("max_query_terms", maxQueryTerms);
}
if (minSimilarity != null) {
builder.field("min_similarity", minSimilarity);

View File

@ -64,7 +64,7 @@ public class FuzzyLikeThisJsonQueryParser extends AbstractIndexComponent impleme
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
JsonParser jp = parseContext.jp();
int maxNumTerms = 100;
int maxNumTerms = 25;
float boost = 1.0f;
List<String> fields = null;
String likeText = null;
@ -80,7 +80,7 @@ public class FuzzyLikeThisJsonQueryParser extends AbstractIndexComponent impleme
} else if (token == JsonToken.VALUE_STRING) {
if ("like_text".equals(currentFieldName)) {
likeText = jp.getText();
} else if ("max_numT_terms".equals(currentFieldName)) {
} else if ("max_query_terms".equals(currentFieldName)) {
maxNumTerms = Integer.parseInt(jp.getText());
} else if ("boost".equals(currentFieldName)) {
boost = Float.parseFloat(jp.getText());
@ -88,7 +88,7 @@ public class FuzzyLikeThisJsonQueryParser extends AbstractIndexComponent impleme
ignoreTF = Booleans.parseBoolean(jp.getText(), false);
}
} else if (token == JsonToken.VALUE_NUMBER_INT) {
if ("max_num_terms".equals(currentFieldName)) {
if ("max_query_terms".equals(currentFieldName)) {
maxNumTerms = jp.getIntValue();
} else if ("boost".equals(currentFieldName)) {
boost = jp.getIntValue();

View File

@ -748,7 +748,7 @@ public class SimpleJsonIndexQueryParserTests {
@Test public void testFuzzyLikeThisBuilder() throws Exception {
IndexQueryParser queryParser = newQueryParser();
Query parsedQuery = queryParser.parse(fuzzyLikeThisQuery("name.first", "name.last").likeText("something").maxNumTerms(12));
Query parsedQuery = queryParser.parse(fuzzyLikeThisQuery("name.first", "name.last").likeText("something").maxQueryTerms(12));
assertThat(parsedQuery, instanceOf(FuzzyLikeThisQuery.class));
// FuzzyLikeThisQuery fuzzyLikeThisQuery = (FuzzyLikeThisQuery) parsedQuery;
}
@ -763,7 +763,7 @@ public class SimpleJsonIndexQueryParserTests {
@Test public void testFuzzyLikeFieldThisBuilder() throws Exception {
IndexQueryParser queryParser = newQueryParser();
Query parsedQuery = queryParser.parse(fuzzyLikeThisFieldQuery("name.first").likeText("something").maxNumTerms(12));
Query parsedQuery = queryParser.parse(fuzzyLikeThisFieldQuery("name.first").likeText("something").maxQueryTerms(12));
assertThat(parsedQuery, instanceOf(FuzzyLikeThisQuery.class));
// FuzzyLikeThisQuery fuzzyLikeThisQuery = (FuzzyLikeThisQuery) parsedQuery;
}

View File

@ -2,6 +2,6 @@
fuzzy_like_this : {
fields : ["name.first", "name.last"],
like_text : "something",
max_num_terms : 12
max_query_terms : 12
}
}

View File

@ -2,7 +2,7 @@
fuzzy_like_this_field : {
"name.first" : {
like_text : "something",
max_num_terms : 12
max_query_terms : 12
}
}
}