Internal: simplify SimpleQueryStringBuilder#doXContent method
No need to test for null values in fieldsAndWeights map, we use 1.0f a default boost all the time.
This commit is contained in:
parent
11b41f1d68
commit
95f3817182
|
@ -63,6 +63,8 @@ public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQuerySt
|
|||
/** Name for (de-)serialization. */
|
||||
public static final String NAME = "simple_query_string";
|
||||
|
||||
static final SimpleQueryStringBuilder PROTOTYPE = new SimpleQueryStringBuilder(null);
|
||||
|
||||
/** Query text to parse. */
|
||||
private final String queryText;
|
||||
/**
|
||||
|
@ -86,8 +88,6 @@ public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQuerySt
|
|||
/** Further search settings needed by the ES specific query string parser only. */
|
||||
private Settings settings = new Settings();
|
||||
|
||||
static final SimpleQueryStringBuilder PROTOTYPE = new SimpleQueryStringBuilder(null);
|
||||
|
||||
/** Construct a new simple query with this query string. */
|
||||
public SimpleQueryStringBuilder(String queryText) {
|
||||
this.queryText = queryText;
|
||||
|
@ -320,13 +320,7 @@ public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQuerySt
|
|||
if (fieldsAndWeights.size() > 0) {
|
||||
builder.startArray("fields");
|
||||
for (Map.Entry<String, Float> entry : fieldsAndWeights.entrySet()) {
|
||||
String field = entry.getKey();
|
||||
Float boost = entry.getValue();
|
||||
if (boost != null) {
|
||||
builder.value(field + "^" + boost);
|
||||
} else {
|
||||
builder.value(field);
|
||||
}
|
||||
builder.value(entry.getKey() + "^" + entry.getValue());
|
||||
}
|
||||
builder.endArray();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue