Fix references to the removed parsers

Mostly stuff is just in the builder now.
This commit is contained in:
Nik Everett 2016-04-05 17:27:29 -04:00
parent c68a58b67e
commit 2b6866d26b
9 changed files with 30 additions and 39 deletions

View File

@ -43,10 +43,7 @@ import org.elasticsearch.index.query.PercolatorQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.index.query.TemplateQueryParser;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
import org.elasticsearch.rest.action.support.RestActions;
import org.elasticsearch.script.Template;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.AggregatorParsers;

View File

@ -60,7 +60,7 @@ import static org.elasticsearch.common.xcontent.support.XContentMapValues.lenien
* FieldMapper for indexing {@link org.locationtech.spatial4j.shape.Shape}s.
* <p>
* Currently Shapes can only be indexed and can only be queried using
* {@link org.elasticsearch.index.query.GeoShapeQueryParser}, consequently
* {@link org.elasticsearch.index.query.GeoShapeQueryBuilder}, consequently
* a lot of behavior in this Mapper is disabled.
* <p>
* Format supported:

View File

@ -75,7 +75,7 @@ public class PercolatorQueryBuilder extends AbstractQueryBuilder<PercolatorQuery
public static final PercolatorQueryBuilder PROTO = new PercolatorQueryBuilder(null, null, null, null, null, null, null, null);
private static final ParseField DOCUMENT_FIELD = new ParseField("document");
static final ParseField DOCUMENT_FIELD = new ParseField("document");
private static final ParseField DOCUMENT_TYPE_FIELD = new ParseField("document_type");
private static final ParseField INDEXED_DOCUMENT_FIELD_INDEX = new ParseField("index");
private static final ParseField INDEXED_DOCUMENT_FIELD_TYPE = new ParseField("type");

View File

@ -33,7 +33,7 @@ import org.elasticsearch.common.xcontent.XContent;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.index.query.TemplateQueryParser;
import org.elasticsearch.index.query.TemplateQueryBuilder;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestChannel;
@ -190,7 +190,7 @@ public class RestMultiSearchAction extends BaseRestHandler {
try (XContentParser parser = XContentFactory.xContent(slice).createParser(slice)) {
queryParseContext.reset(parser);
queryParseContext.parseFieldMatcher(parseFieldMatcher);
Template template = TemplateQueryParser.parse(parser, queryParseContext.parseFieldMatcher(), "params", "template");
Template template = TemplateQueryBuilder.parse(parser, queryParseContext.parseFieldMatcher(), "params", "template");
searchRequest.template(template);
}
} else {

View File

@ -32,7 +32,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.index.query.TemplateQueryParser;
import org.elasticsearch.index.query.TemplateQueryBuilder;
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestChannel;
@ -48,8 +48,8 @@ import org.elasticsearch.search.fetch.source.FetchSourceContext;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.search.suggest.SuggestBuilder;
import org.elasticsearch.search.suggest.term.TermSuggestionBuilder.SuggestMode;
import org.elasticsearch.search.suggest.Suggesters;
import org.elasticsearch.search.suggest.term.TermSuggestionBuilder.SuggestMode;
import java.io.IOException;
import java.util.Arrays;
@ -127,7 +127,7 @@ public class RestSearchAction extends BaseRestHandler {
context.reset(parser);
context.parseFieldMatcher(parseFieldMatcher);
if (isTemplateRequest) {
Template template = TemplateQueryParser.parse(parser, context.parseFieldMatcher(), "params", "template");
Template template = TemplateQueryBuilder.parse(parser, context.parseFieldMatcher(), "params", "template");
searchRequest.template(template);
} else {
searchRequest.source().parseXContent(parser, context, aggParsers, suggesters);

View File

@ -55,7 +55,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.query.TemplateQueryParser;
import org.elasticsearch.index.query.TemplateQueryBuilder;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.watcher.FileChangesListener;
import org.elasticsearch.watcher.FileWatcher;
@ -364,7 +364,7 @@ public class ScriptService extends AbstractComponent implements Closeable {
try {
XContentParser parser = XContentFactory.xContent(scriptBytes).createParser(scriptBytes);
parser.nextToken();
Template template = TemplateQueryParser.parse(scriptLang, parser, parseFieldMatcher, "params", "script", "template");
Template template = TemplateQueryBuilder.parse(scriptLang, parser, parseFieldMatcher, "params", "script", "template");
if (Strings.hasLength(template.getScript())) {
//Just try and compile it
try {

View File

@ -40,13 +40,13 @@ import java.io.IOException;
import java.util.Collections;
import java.util.Set;
import static java.util.Collections.singleton;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
public class PercolatorQueryBuilderTests extends AbstractQueryTestCase<PercolatorQueryBuilder> {
private static final Set<String> SHUFFLE_PROTECTED_FIELDS =
Collections.singleton(PercolatorQueryParser.DOCUMENT_FIELD.getPreferredName());
private static final Set<String> SHUFFLE_PROTECTED_FIELDS = singleton(PercolatorQueryBuilder.DOCUMENT_FIELD.getPreferredName());
private String indexedDocumentIndex;
private String indexedDocumentType;
private String indexedDocumentId;

View File

@ -18,6 +18,10 @@
*/
package org.elasticsearch.messy.tests;
import java.io.IOException;
import java.lang.reflect.Proxy;
import java.util.Collections;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.util.Accountable;
@ -48,7 +52,7 @@ import org.elasticsearch.index.fielddata.IndexFieldDataService;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.index.query.TemplateQueryParser;
import org.elasticsearch.index.query.TemplateQueryBuilder;
import org.elasticsearch.index.query.functionscore.ScoreFunctionParser;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.similarity.SimilarityService;
@ -71,10 +75,6 @@ import org.elasticsearch.threadpool.ThreadPoolModule;
import org.junit.After;
import org.junit.Before;
import java.io.IOException;
import java.lang.reflect.Proxy;
import java.util.Collections;
import static org.hamcrest.Matchers.containsString;
/**
@ -166,8 +166,7 @@ public class TemplateQueryParserTests extends ESTestCase {
context.reset(templateSourceParser);
templateSourceParser.nextToken();
TemplateQueryParser parser = injector.getInstance(TemplateQueryParser.class);
Query query = QueryBuilder.rewriteQuery(parser.fromXContent(context.parseContext()), context).toQuery(context);
Query query = QueryBuilder.rewriteQuery(TemplateQueryBuilder.fromXContent(context.parseContext()), context).toQuery(context);
assertTrue("Parsing template query failed.", query instanceof MatchAllDocsQuery);
}
@ -177,8 +176,7 @@ public class TemplateQueryParserTests extends ESTestCase {
XContentParser templateSourceParser = XContentFactory.xContent(templateString).createParser(templateString);
context.reset(templateSourceParser);
TemplateQueryParser parser = injector.getInstance(TemplateQueryParser.class);
Query query = QueryBuilder.rewriteQuery(parser.fromXContent(context.parseContext()), context).toQuery(context);
Query query = QueryBuilder.rewriteQuery(TemplateQueryBuilder.fromXContent(context.parseContext()), context).toQuery(context);
assertTrue("Parsing template query failed.", query instanceof MatchAllDocsQuery);
}
@ -194,9 +192,8 @@ public class TemplateQueryParserTests extends ESTestCase {
XContentParser templateSourceParser = XContentFactory.xContent(templateString).createParser(templateString);
context.reset(templateSourceParser);
TemplateQueryParser parser = injector.getInstance(TemplateQueryParser.class);
try {
parser.fromXContent(context.parseContext()).rewrite(context);
TemplateQueryBuilder.fromXContent(context.parseContext()).rewrite(context);
fail("Expected ParsingException");
} catch (ParsingException e) {
assertThat(e.getMessage(), containsString("query malformed, no field after start_object"));
@ -211,8 +208,7 @@ public class TemplateQueryParserTests extends ESTestCase {
templateSourceParser.nextToken();
TemplateQueryParser parser = injector.getInstance(TemplateQueryParser.class);
Query query = QueryBuilder.rewriteQuery(parser.fromXContent(context.parseContext()), context).toQuery(context);
Query query = QueryBuilder.rewriteQuery(TemplateQueryBuilder.fromXContent(context.parseContext()), context).toQuery(context);
assertTrue("Parsing template query failed.", query instanceof MatchAllDocsQuery);
}
@ -222,9 +218,8 @@ public class TemplateQueryParserTests extends ESTestCase {
XContentParser templateSourceParser = XContentFactory.xContent(templateString).createParser(templateString);
context.reset(templateSourceParser);
templateSourceParser.nextToken();
TemplateQueryParser parser = injector.getInstance(TemplateQueryParser.class);
try {
parser.fromXContent(context.parseContext()).toQuery(context);
TemplateQueryBuilder.fromXContent(context.parseContext()).toQuery(context);
fail();
} catch (UnsupportedOperationException ex) {
assertEquals("this query must be rewritten first", ex.getMessage());

View File

@ -18,6 +18,14 @@
*/
package org.elasticsearch.messy.tests;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.elasticsearch.action.index.IndexRequest.OpType;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.indexedscripts.delete.DeleteIndexedScriptResponse;
@ -34,7 +42,6 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TemplateQueryBuilder;
import org.elasticsearch.index.query.TemplateQueryParser;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptService.ScriptType;
@ -45,14 +52,6 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Before;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFailures;
@ -155,7 +154,7 @@ public class TemplateQueryTests extends ESIntegTestCase {
private Template parseTemplate(String template) throws IOException {
try (XContentParser parser = XContentFactory.xContent(template).createParser(template)) {
return TemplateQueryParser.parse(parser, ParseFieldMatcher.EMPTY, "params", "template");
return TemplateQueryBuilder.parse(parser, ParseFieldMatcher.EMPTY, "params", "template");
}
}