Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int
return new FuzzyQuery(createTerm(value), fuzziness.asDistance(BytesRefs.toString(value)), prefixLength, maxExpansions, transpositions);
}

public Query prefixQuery(Object value, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) {
public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) {
PrefixQuery query = new PrefixQuery(createTerm(value));
if (method != null) {
query.setRewriteMethod(method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public Query termsQuery(List values, @Nullable QueryParseContext context) {
}

@Override
public Query prefixQuery(Object value, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) {
public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) {
if (indexOptions() != IndexOptions.NONE || context == null) {
return super.prefixQuery(value, method, context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
String rewriteMethod = null;
String queryName = null;

Object value = null;
String value = null;
float boost = 1.0f;
String currentFieldName = null;
XContentParser.Token token;
Expand All @@ -73,7 +73,7 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
if ("_name".equals(currentFieldName)) {
queryName = parser.text();
} else if ("value".equals(currentFieldName) || "prefix".equals(currentFieldName)) {
value = parser.objectBytes();
value = parser.textOrNull();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as in the regex PR, I wonder if we should have parser.text() or parser.textOrNull()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reasoning here is that we check for null at the end and return a probably more comprehensive error message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me

} else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue();
} else if ("rewrite".equals(currentFieldName)) {
Expand All @@ -88,7 +88,7 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
queryName = parser.text();
} else {
fieldName = currentFieldName;
value = parser.objectBytes();
value = parser.textOrNull();
}
}
}
Expand Down