[TEST] refactor DummyQueryBuilder and corresponding parser
DummyQueryParser properly implements now fromXContent and the corresponding builder supports converting to the corresponding lucene query through toQuery method.
This commit is contained in:
parent
1420482f86
commit
cc408ddd45
|
@ -55,23 +55,28 @@ public class DummyQueryParserPlugin extends Plugin {
|
|||
builder.startObject(NAME).endObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Query doToQuery(QueryShardContext context) throws IOException {
|
||||
return new DummyQuery(context.isFilter());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DummyQueryParser extends BaseQueryParserTemp {
|
||||
public static class DummyQueryParser extends BaseQueryParser {
|
||||
@Override
|
||||
public String[] names() {
|
||||
return new String[]{DummyQueryBuilder.NAME};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(QueryShardContext context) throws IOException, QueryShardException {
|
||||
XContentParser.Token token = context.parseContext().parser().nextToken();
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
XContentParser.Token token = parseContext.parser().nextToken();
|
||||
assert token == XContentParser.Token.END_OBJECT;
|
||||
return new DummyQuery(context.isFilter());
|
||||
return new DummyQueryBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue