fix compile errors

This commit is contained in:
Colin Goodheart-Smithe 2015-09-23 11:07:20 +01:00
parent b98f7cf023
commit ac8c1722ac
4 changed files with 39 additions and 45 deletions

View File

@ -28,7 +28,6 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.indices.query.IndicesQueriesRegistry; import org.elasticsearch.indices.query.IndicesQueriesRegistry;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -77,7 +76,7 @@ public class RestPutWarmerAction extends BaseRestHandler {
BytesReference sourceBytes = RestActions.getRestContent(request); BytesReference sourceBytes = RestActions.getRestContent(request);
XContentParser parser = XContentFactory.xContent(sourceBytes).createParser(sourceBytes); XContentParser parser = XContentFactory.xContent(sourceBytes).createParser(sourceBytes);
QueryParseContext queryParseContext = new QueryParseContext(new Index(""), queryRegistry); // NORELEASE remove index QueryParseContext queryParseContext = new QueryParseContext(queryRegistry);
queryParseContext.reset(parser); queryParseContext.reset(parser);
SearchSourceBuilder source = SearchSourceBuilder.PROTOTYPE.fromXContent(parser, queryParseContext); SearchSourceBuilder source = SearchSourceBuilder.PROTOTYPE.fromXContent(parser, queryParseContext);
SearchRequest searchRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index"))) SearchRequest searchRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index")))

View File

@ -31,7 +31,6 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.Index;
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.indices.query.IndicesQueriesRegistry; import org.elasticsearch.indices.query.IndicesQueriesRegistry;
@ -106,11 +105,11 @@ public class RestSearchAction extends BaseRestHandler {
if (isTemplateRequest) { if (isTemplateRequest) {
searchRequest.templateSource(RestActions.getRestContent(request)); searchRequest.templateSource(RestActions.getRestContent(request));
} else { } else {
BytesReference sourceBytes = RestActions.getRestContent(request); BytesReference sourceBytes = RestActions.getRestContent(request);
XContentParser parser = XContentFactory.xContent(sourceBytes).createParser(sourceBytes); XContentParser parser = XContentFactory.xContent(sourceBytes).createParser(sourceBytes);
QueryParseContext queryParseContext = new QueryParseContext(new Index(""), queryRegistry); // NORELEASE remove index QueryParseContext queryParseContext = new QueryParseContext(queryRegistry);
queryParseContext.reset(parser); queryParseContext.reset(parser);
searchRequest.source(SearchSourceBuilder.PROTOTYPE.fromXContent(parser, queryParseContext)); searchRequest.source(SearchSourceBuilder.PROTOTYPE.fromXContent(parser, queryParseContext));
} }
} }

View File

@ -687,8 +687,8 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
XContentParser.Token token; XContentParser.Token token;
String currentFieldName = null; String currentFieldName = null;
if ((token = parser.nextToken()) != XContentParser.Token.START_OBJECT) { if ((token = parser.nextToken()) != XContentParser.Token.START_OBJECT) {
throw new ParsingException(context, "Expected [" + XContentParser.Token.START_OBJECT + "] but found [" + token + "]", throw new ParsingException(parser.getTokenLocation(), "Expected [" + XContentParser.Token.START_OBJECT + "] but found ["
parser.getTokenLocation()); + token + "]");
} }
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
@ -718,8 +718,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
fieldNames.add(parser.text()); fieldNames.add(parser.text());
builder.fieldNames = fieldNames; builder.fieldNames = fieldNames;
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].");
parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.START_OBJECT) { } else if (token == XContentParser.Token.START_OBJECT) {
if (context.parseFieldMatcher().match(currentFieldName, QUERY_FIELD)) { if (context.parseFieldMatcher().match(currentFieldName, QUERY_FIELD)) {
@ -743,24 +742,25 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
scriptFields scriptFields
.add(new ScriptField(scriptFieldName, Script.parse(parser, context.parseFieldMatcher()))); .add(new ScriptField(scriptFieldName, Script.parse(parser, context.parseFieldMatcher())));
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in ["
+ "].", parser.getTokenLocation()); + currentFieldName + "].");
} }
} else if (token == XContentParser.Token.START_OBJECT) { } else if (token == XContentParser.Token.START_OBJECT) {
if (context.parseFieldMatcher().match(currentFieldName, SCRIPT_FIELD)) { if (context.parseFieldMatcher().match(currentFieldName, SCRIPT_FIELD)) {
scriptFields scriptFields
.add(new ScriptField(scriptFieldName, Script.parse(parser, context.parseFieldMatcher()))); .add(new ScriptField(scriptFieldName, Script.parse(parser, context.parseFieldMatcher())));
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in ["
+ "].", parser.getTokenLocation()); + currentFieldName + "].");
} }
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in ["
+ "].", parser.getTokenLocation()); + currentFieldName + "].");
} }
} }
} else { } else {
throw new ParsingException(context, "Expected [" + XContentParser.Token.START_OBJECT + "] in [" throw new ParsingException(parser.getTokenLocation(), "Expected [" + XContentParser.Token.START_OBJECT
+ "] in ["
+ currentFieldName + "] but found [" + token + "]", parser.getTokenLocation()); + currentFieldName + "] but found [" + token + "]", parser.getTokenLocation());
} }
} }
@ -773,8 +773,8 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
} else if (token.isValue()) { } else if (token.isValue()) {
indexBoost.put(currentFieldName, parser.floatValue()); indexBoost.put(currentFieldName, parser.floatValue());
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName
parser.getTokenLocation()); + "].");
} }
} }
builder.indexBoost = indexBoost; builder.indexBoost = indexBoost;
@ -791,8 +791,8 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
xContentBuilder.endObject(); xContentBuilder.endObject();
aggregations.add(xContentBuilder.bytes()); aggregations.add(xContentBuilder.bytes());
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName
parser.getTokenLocation()); + "].");
} }
} }
builder.aggregations = aggregations; builder.aggregations = aggregations;
@ -806,8 +806,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
XContentBuilder xContentBuilder = XContentFactory.contentBuilder(parser.contentType()).copyCurrentStructure(parser); XContentBuilder xContentBuilder = XContentFactory.contentBuilder(parser.contentType()).copyCurrentStructure(parser);
builder.suggestBuilder = xContentBuilder.bytes(); builder.suggestBuilder = xContentBuilder.bytes();
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].");
parser.getTokenLocation());
} }
} else if (token == XContentParser.Token.START_ARRAY) { } else if (token == XContentParser.Token.START_ARRAY) {
if (context.parseFieldMatcher().match(currentFieldName, FIELDS_FIELD)) { if (context.parseFieldMatcher().match(currentFieldName, FIELDS_FIELD)) {
@ -816,8 +815,8 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
fieldNames.add(parser.text()); fieldNames.add(parser.text());
} else { } else {
throw new ParsingException(context, "Expected [" + XContentParser.Token.VALUE_STRING + "] in [" throw new ParsingException(parser.getTokenLocation(), "Expected [" + XContentParser.Token.VALUE_STRING
+ currentFieldName + "] but found [" + token + "]", parser.getTokenLocation()); + "] in [" + currentFieldName + "] but found [" + token + "]");
} }
} }
builder.fieldNames = fieldNames; builder.fieldNames = fieldNames;
@ -827,8 +826,8 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
fieldDataFields.add(parser.text()); fieldDataFields.add(parser.text());
} else { } else {
throw new ParsingException(context, "Expected [" + XContentParser.Token.VALUE_STRING + "] in [" throw new ParsingException(parser.getTokenLocation(), "Expected [" + XContentParser.Token.VALUE_STRING
+ currentFieldName + "] but found [" + token + "]", parser.getTokenLocation()); + "] in [" + currentFieldName + "] but found [" + token + "]");
} }
} }
builder.fieldDataFields = fieldDataFields; builder.fieldDataFields = fieldDataFields;
@ -852,18 +851,16 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
stats.add(parser.text()); stats.add(parser.text());
} else { } else {
throw new ParsingException(context, "Expected [" + XContentParser.Token.VALUE_STRING + "] in [" throw new ParsingException(parser.getTokenLocation(), "Expected [" + XContentParser.Token.VALUE_STRING
+ currentFieldName + "] but found [" + token + "]", parser.getTokenLocation()); + "] in [" + currentFieldName + "] but found [" + token + "]");
} }
} }
builder.stats = stats.toArray(new String[stats.size()]); builder.stats = stats.toArray(new String[stats.size()]);
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].");
parser.getTokenLocation());
} }
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].");
parser.getTokenLocation());
} }
} }
return builder; return builder;

View File

@ -206,8 +206,8 @@ public class FetchSourceContext implements Streamable, ToXContent {
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
includesList.add(parser.text()); includesList.add(parser.text());
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in ["
parser.getTokenLocation()); + currentFieldName + "].");
} }
} }
includes = includesList.toArray(new String[includesList.size()]); includes = includesList.toArray(new String[includesList.size()]);
@ -217,23 +217,22 @@ public class FetchSourceContext implements Streamable, ToXContent {
if (token == XContentParser.Token.VALUE_STRING) { if (token == XContentParser.Token.VALUE_STRING) {
excludesList.add(parser.text()); excludesList.add(parser.text());
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in ["
parser.getTokenLocation()); + currentFieldName + "].");
} }
} }
excludes = excludesList.toArray(new String[excludesList.size()]); excludes = excludesList.toArray(new String[excludesList.size()]);
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName
parser.getTokenLocation()); + "].");
} }
} else { } else {
throw new ParsingException(context, "Unknown key for a " + token + " in [" + currentFieldName + "].", throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].");
parser.getTokenLocation());
} }
} }
} else { } else {
throw new ParsingException(context, "Expected one of [" + XContentParser.Token.VALUE_BOOLEAN + ", " throw new ParsingException(parser.getTokenLocation(), "Expected one of [" + XContentParser.Token.VALUE_BOOLEAN + ", "
+ XContentParser.Token.START_OBJECT + "] but found [" + token + "]", parser.getTokenLocation()); + XContentParser.Token.START_OBJECT + "] but found [" + token + "]");
} }
this.fetchSource = fetchSource; this.fetchSource = fetchSource;
this.includes = includes; this.includes = includes;