[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();
|
builder.startObject(NAME).endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Query doToQuery(QueryShardContext context) throws IOException {
|
||||||
|
return new DummyQuery(context.isFilter());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWriteableName() {
|
public String getWriteableName() {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DummyQueryParser extends BaseQueryParserTemp {
|
public static class DummyQueryParser extends BaseQueryParser {
|
||||||
@Override
|
@Override
|
||||||
public String[] names() {
|
public String[] names() {
|
||||||
return new String[]{DummyQueryBuilder.NAME};
|
return new String[]{DummyQueryBuilder.NAME};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query parse(QueryShardContext context) throws IOException, QueryShardException {
|
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
XContentParser.Token token = context.parseContext().parser().nextToken();
|
XContentParser.Token token = parseContext.parser().nextToken();
|
||||||
assert token == XContentParser.Token.END_OBJECT;
|
assert token == XContentParser.Token.END_OBJECT;
|
||||||
return new DummyQuery(context.isFilter());
|
return new DummyQueryBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue