Adapting to changes in https://github.com/elastic/elasticsearch/pull/25448 (elastic/x-pack-elasticsearch#1887)
Original commit: elastic/x-pack-elasticsearch@5cdf5a2372
This commit is contained in:
parent
f60c0f893c
commit
7c6b8ffa36
|
@ -28,10 +28,10 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.elasticsearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder;
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.GET;
|
import static org.elasticsearch.rest.RestRequest.Method.GET;
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
||||||
import static org.elasticsearch.xpack.graph.action.GraphExploreAction.INSTANCE;
|
import static org.elasticsearch.xpack.graph.action.GraphExploreAction.INSTANCE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GraphExploreRequest
|
* @see GraphExploreRequest
|
||||||
*/
|
*/
|
||||||
|
@ -121,7 +121,7 @@ public class RestGraphAction extends XPackRestHandler {
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
if (QUERY_FIELD.match(fieldName)) {
|
if (QUERY_FIELD.match(fieldName)) {
|
||||||
currentHop.guidingQuery(context.parseInnerQueryBuilder());
|
currentHop.guidingQuery(parseInnerQueryBuilder(parser));
|
||||||
} else if (CONNECTIONS_FIELD.match(fieldName)) {
|
} else if (CONNECTIONS_FIELD.match(fieldName)) {
|
||||||
parseHop(parser, context, graphRequest.createNextHop(null), graphRequest);
|
parseHop(parser, context, graphRequest.createNextHop(null), graphRequest);
|
||||||
} else if (CONTROLS_FIELD.match(fieldName)) {
|
} else if (CONTROLS_FIELD.match(fieldName)) {
|
||||||
|
@ -221,7 +221,7 @@ public class RestGraphAction extends XPackRestHandler {
|
||||||
"Graph vertices definition cannot contain both "+ INCLUDE_FIELD.getPreferredName()+
|
"Graph vertices definition cannot contain both "+ INCLUDE_FIELD.getPreferredName()+
|
||||||
" and "+EXCLUDE_FIELD.getPreferredName()+" clauses", token.name());
|
" and "+EXCLUDE_FIELD.getPreferredName()+" clauses", token.name());
|
||||||
}
|
}
|
||||||
excludes = new HashSet<String>();
|
excludes = new HashSet<>();
|
||||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
excludes.add(parser.text());
|
excludes.add(parser.text());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
import org.elasticsearch.index.query.AbstractQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
|
@ -87,14 +88,14 @@ public class DatafeedConfig extends AbstractDiffable<DatafeedConfig> implements
|
||||||
PARSER.declareString((builder, val) ->
|
PARSER.declareString((builder, val) ->
|
||||||
builder.setFrequency(TimeValue.parseTimeValue(val, FREQUENCY.getPreferredName())), FREQUENCY);
|
builder.setFrequency(TimeValue.parseTimeValue(val, FREQUENCY.getPreferredName())), FREQUENCY);
|
||||||
PARSER.declareObject(Builder::setQuery,
|
PARSER.declareObject(Builder::setQuery,
|
||||||
(p, c) -> new QueryParseContext(p).parseInnerQueryBuilder(), QUERY);
|
(p, c) -> AbstractQueryBuilder.parseInnerQueryBuilder(p), QUERY);
|
||||||
PARSER.declareObject(Builder::setAggregations, (p, c) -> AggregatorFactories.parseAggregators(new QueryParseContext(p)),
|
PARSER.declareObject(Builder::setAggregations, (p, c) -> AggregatorFactories.parseAggregators(new QueryParseContext(p)),
|
||||||
AGGREGATIONS);
|
AGGREGATIONS);
|
||||||
PARSER.declareObject(Builder::setAggregations,(p, c) -> AggregatorFactories.parseAggregators(new QueryParseContext(p)), AGGS);
|
PARSER.declareObject(Builder::setAggregations,(p, c) -> AggregatorFactories.parseAggregators(new QueryParseContext(p)), AGGS);
|
||||||
PARSER.declareObject(Builder::setScriptFields, (p, c) -> {
|
PARSER.declareObject(Builder::setScriptFields, (p, c) -> {
|
||||||
List<SearchSourceBuilder.ScriptField> parsedScriptFields = new ArrayList<>();
|
List<SearchSourceBuilder.ScriptField> parsedScriptFields = new ArrayList<>();
|
||||||
while (p.nextToken() != XContentParser.Token.END_OBJECT) {
|
while (p.nextToken() != XContentParser.Token.END_OBJECT) {
|
||||||
parsedScriptFields.add(new SearchSourceBuilder.ScriptField(new QueryParseContext(p)));
|
parsedScriptFields.add(new SearchSourceBuilder.ScriptField(p));
|
||||||
}
|
}
|
||||||
parsedScriptFields.sort(Comparator.comparing(SearchSourceBuilder.ScriptField::fieldName));
|
parsedScriptFields.sort(Comparator.comparing(SearchSourceBuilder.ScriptField::fieldName));
|
||||||
return parsedScriptFields;
|
return parsedScriptFields;
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
import org.elasticsearch.index.query.AbstractQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
|
@ -49,7 +50,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
||||||
PARSER.declareString((builder, val) -> builder.setFrequency(
|
PARSER.declareString((builder, val) -> builder.setFrequency(
|
||||||
TimeValue.parseTimeValue(val, DatafeedConfig.FREQUENCY.getPreferredName())), DatafeedConfig.FREQUENCY);
|
TimeValue.parseTimeValue(val, DatafeedConfig.FREQUENCY.getPreferredName())), DatafeedConfig.FREQUENCY);
|
||||||
PARSER.declareObject(Builder::setQuery,
|
PARSER.declareObject(Builder::setQuery,
|
||||||
(p, c) -> new QueryParseContext(p).parseInnerQueryBuilder(), DatafeedConfig.QUERY);
|
(p, c) -> AbstractQueryBuilder.parseInnerQueryBuilder(p), DatafeedConfig.QUERY);
|
||||||
PARSER.declareObject(Builder::setAggregations, (p, c) -> AggregatorFactories.parseAggregators(new QueryParseContext(p)),
|
PARSER.declareObject(Builder::setAggregations, (p, c) -> AggregatorFactories.parseAggregators(new QueryParseContext(p)),
|
||||||
DatafeedConfig.AGGREGATIONS);
|
DatafeedConfig.AGGREGATIONS);
|
||||||
PARSER.declareObject(Builder::setAggregations,(p, c) -> AggregatorFactories.parseAggregators(new QueryParseContext(p)),
|
PARSER.declareObject(Builder::setAggregations,(p, c) -> AggregatorFactories.parseAggregators(new QueryParseContext(p)),
|
||||||
|
@ -57,7 +58,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
||||||
PARSER.declareObject(Builder::setScriptFields, (p, c) -> {
|
PARSER.declareObject(Builder::setScriptFields, (p, c) -> {
|
||||||
List<SearchSourceBuilder.ScriptField> parsedScriptFields = new ArrayList<>();
|
List<SearchSourceBuilder.ScriptField> parsedScriptFields = new ArrayList<>();
|
||||||
while (p.nextToken() != XContentParser.Token.END_OBJECT) {
|
while (p.nextToken() != XContentParser.Token.END_OBJECT) {
|
||||||
parsedScriptFields.add(new SearchSourceBuilder.ScriptField(new QueryParseContext(p)));
|
parsedScriptFields.add(new SearchSourceBuilder.ScriptField(p));
|
||||||
}
|
}
|
||||||
parsedScriptFields.sort(Comparator.comparing(SearchSourceBuilder.ScriptField::fieldName));
|
parsedScriptFields.sort(Comparator.comparing(SearchSourceBuilder.ScriptField::fieldName));
|
||||||
return parsedScriptFields;
|
return parsedScriptFields;
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
|
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
|
||||||
import org.elasticsearch.index.engine.EngineException;
|
import org.elasticsearch.index.engine.EngineException;
|
||||||
|
import org.elasticsearch.index.query.AbstractQueryBuilder;
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
import org.elasticsearch.index.query.BoostingQueryBuilder;
|
import org.elasticsearch.index.query.BoostingQueryBuilder;
|
||||||
import org.elasticsearch.index.query.ConstantScoreQueryBuilder;
|
import org.elasticsearch.index.query.ConstantScoreQueryBuilder;
|
||||||
|
@ -134,7 +135,7 @@ public class SecurityIndexSearcherWrapper extends IndexSearcherWrapper {
|
||||||
String templateResult = evaluateTemplate(bytesReference.utf8ToString());
|
String templateResult = evaluateTemplate(bytesReference.utf8ToString());
|
||||||
try (XContentParser parser = XContentFactory.xContent(templateResult)
|
try (XContentParser parser = XContentFactory.xContent(templateResult)
|
||||||
.createParser(queryShardContext.getXContentRegistry(), templateResult)) {
|
.createParser(queryShardContext.getXContentRegistry(), templateResult)) {
|
||||||
QueryBuilder queryBuilder = queryShardContext.newParseContext(parser).parseInnerQueryBuilder();
|
QueryBuilder queryBuilder = AbstractQueryBuilder.parseInnerQueryBuilder(parser);
|
||||||
verifyRoleQuery(queryBuilder);
|
verifyRoleQuery(queryBuilder);
|
||||||
failIfQueryUsesClient(scriptService, queryBuilder, queryShardContext);
|
failIfQueryUsesClient(scriptService, queryBuilder, queryShardContext);
|
||||||
ParsedQuery parsedQuery = queryShardContext.toFilter(queryBuilder);
|
ParsedQuery parsedQuery = queryShardContext.toFilter(queryBuilder);
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.common.xcontent.json.JsonXContentParser;
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
|
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
|
||||||
import org.elasticsearch.index.mapper.MapperService;
|
import org.elasticsearch.index.mapper.MapperService;
|
||||||
|
import org.elasticsearch.index.query.AbstractQueryBuilder;
|
||||||
import org.elasticsearch.index.query.ParsedQuery;
|
import org.elasticsearch.index.query.ParsedQuery;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
|
@ -145,7 +146,7 @@ public class SecurityIndexSearcherWrapperIntegrationTests extends ESTestCase {
|
||||||
for (int i = 0; i < numValues; i++) {
|
for (int i = 0; i < numValues; i++) {
|
||||||
ParsedQuery parsedQuery = new ParsedQuery(new TermQuery(new Term("field", values[i])));
|
ParsedQuery parsedQuery = new ParsedQuery(new TermQuery(new Term("field", values[i])));
|
||||||
when(queryShardContext.newParseContext(anyParser())).thenReturn(queryParseContext);
|
when(queryShardContext.newParseContext(anyParser())).thenReturn(queryParseContext);
|
||||||
when(queryParseContext.parseInnerQueryBuilder()).thenReturn(new TermQueryBuilder("field", values[i]));
|
when(AbstractQueryBuilder.parseInnerQueryBuilder(anyParser())).thenReturn(new TermQueryBuilder("field", values[i]));
|
||||||
when(queryShardContext.toFilter(new TermsQueryBuilder("field", values[i]))).thenReturn(parsedQuery);
|
when(queryShardContext.toFilter(new TermsQueryBuilder("field", values[i]))).thenReturn(parsedQuery);
|
||||||
DirectoryReader wrappedDirectoryReader = wrapper.wrap(directoryReader);
|
DirectoryReader wrappedDirectoryReader = wrapper.wrap(directoryReader);
|
||||||
IndexSearcher indexSearcher = wrapper.wrap(new IndexSearcher(wrappedDirectoryReader));
|
IndexSearcher indexSearcher = wrapper.wrap(new IndexSearcher(wrappedDirectoryReader));
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.query.MatchAllQueryBuilder;
|
import org.elasticsearch.index.query.MatchAllQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
|
||||||
import org.elasticsearch.index.query.ScriptQueryBuilder;
|
import org.elasticsearch.index.query.ScriptQueryBuilder;
|
||||||
import org.elasticsearch.license.XPackLicenseState;
|
import org.elasticsearch.license.XPackLicenseState;
|
||||||
import org.elasticsearch.script.Script;
|
import org.elasticsearch.script.Script;
|
||||||
|
@ -556,9 +555,9 @@ public class WatchTests extends ESTestCase {
|
||||||
protected NamedXContentRegistry xContentRegistry() {
|
protected NamedXContentRegistry xContentRegistry() {
|
||||||
return new NamedXContentRegistry(Arrays.asList(
|
return new NamedXContentRegistry(Arrays.asList(
|
||||||
new NamedXContentRegistry.Entry(QueryBuilder.class, new ParseField(MatchAllQueryBuilder.NAME), (p, c) ->
|
new NamedXContentRegistry.Entry(QueryBuilder.class, new ParseField(MatchAllQueryBuilder.NAME), (p, c) ->
|
||||||
MatchAllQueryBuilder.fromXContent((QueryParseContext) c)),
|
MatchAllQueryBuilder.fromXContent(p)),
|
||||||
new NamedXContentRegistry.Entry(QueryBuilder.class, new ParseField(ScriptQueryBuilder.NAME), (p, c) ->
|
new NamedXContentRegistry.Entry(QueryBuilder.class, new ParseField(ScriptQueryBuilder.NAME), (p, c) ->
|
||||||
ScriptQueryBuilder.fromXContent((QueryParseContext) c))
|
ScriptQueryBuilder.fromXContent(p))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue