mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-26 14:54:56 +00:00
Merge branch 'master' into feature/query-refactoring
This commit is contained in:
commit
1228a9fe55
@ -504,7 +504,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
||||
exceptions.put(org.elasticsearch.index.mapper.MapperException.class, 37);
|
||||
exceptions.put(org.elasticsearch.indices.InvalidTypeNameException.class, 38);
|
||||
exceptions.put(org.elasticsearch.snapshots.SnapshotRestoreException.class, 39);
|
||||
exceptions.put(org.elasticsearch.index.query.QueryParsingException.class, 40);
|
||||
exceptions.put(org.elasticsearch.common.ParsingException.class, 40);
|
||||
exceptions.put(org.elasticsearch.index.shard.IndexShardClosedException.class, 41);
|
||||
exceptions.put(org.elasticsearch.script.expression.ExpressionScriptCompilationException.class, 42);
|
||||
exceptions.put(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class, 43);
|
||||
|
@ -43,7 +43,7 @@ import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
import org.elasticsearch.index.query.QueryShardException;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
@ -190,7 +190,7 @@ public class TransportValidateQueryAction extends TransportBroadcastAction<Valid
|
||||
if (request.rewrite()) {
|
||||
explanation = getRewrittenQuery(searcher.searcher(), searchContext.query());
|
||||
}
|
||||
} catch (QueryShardException|QueryParsingException e) {
|
||||
} catch (QueryShardException|ParsingException e) {
|
||||
valid = false;
|
||||
error = e.getDetailedMessage();
|
||||
} catch (AssertionError|IOException e) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
package org.elasticsearch.common;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
@ -26,6 +26,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentLocation;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -34,22 +35,25 @@ import java.io.IOException;
|
||||
* Exception that can be used when parsing queries with a given {@link QueryParseContext}.
|
||||
* Can contain information about location of the error.
|
||||
*/
|
||||
public class QueryParsingException extends ElasticsearchException {
|
||||
public class ParsingException extends ElasticsearchException {
|
||||
|
||||
static final int UNKNOWN_POSITION = -1;
|
||||
protected static final int UNKNOWN_POSITION = -1;
|
||||
private final int lineNumber;
|
||||
private final int columnNumber;
|
||||
|
||||
public QueryParsingException(QueryParseContext parseContext, String msg, Object... args) {
|
||||
public ParsingException(QueryParseContext parseContext, String msg, Object... args) {
|
||||
this(parseContext, msg, null, args);
|
||||
}
|
||||
|
||||
public QueryParsingException(QueryParseContext parseContext, String msg, Throwable cause, Object... args) {
|
||||
public ParsingException(QueryParseContext parseContext, String msg, Throwable cause, Object... args) {
|
||||
this(parseContext.index(), parseContext.parser(), msg, cause, args);
|
||||
}
|
||||
|
||||
public ParsingException(Index index, XContentParser parser, String msg, Throwable cause, Object... args) {
|
||||
super(msg, cause, args);
|
||||
setIndex(parseContext.index());
|
||||
setIndex(index);
|
||||
int lineNumber = UNKNOWN_POSITION;
|
||||
int columnNumber = UNKNOWN_POSITION;
|
||||
XContentParser parser = parseContext.parser();
|
||||
if (parser != null) {
|
||||
XContentLocation location = parser.getTokenLocation();
|
||||
if (location != null) {
|
||||
@ -65,14 +69,14 @@ public class QueryParsingException extends ElasticsearchException {
|
||||
* This constructor is provided for use in unit tests where a
|
||||
* {@link QueryParseContext} may not be available
|
||||
*/
|
||||
public QueryParsingException(Index index, int line, int col, String msg, Throwable cause) {
|
||||
public ParsingException(Index index, int line, int col, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
setIndex(index);
|
||||
this.lineNumber = line;
|
||||
this.columnNumber = col;
|
||||
}
|
||||
|
||||
public QueryParsingException(StreamInput in) throws IOException{
|
||||
public ParsingException(StreamInput in) throws IOException{
|
||||
super(in);
|
||||
lineNumber = in.readInt();
|
||||
columnNumber = in.readInt();
|
@ -44,7 +44,7 @@ import org.elasticsearch.index.mapper.internal.TypeFieldMapper;
|
||||
import org.elasticsearch.index.percolator.stats.ShardPercolateService;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
@ -210,7 +210,7 @@ public class PercolatorQueriesRegistry extends AbstractIndexShardComponent imple
|
||||
context.setMapUnmappedFieldAsString(mapUnmappedFieldsAsString ? true : false);
|
||||
return queryParserService.parseInnerQuery(context);
|
||||
} catch (IOException e) {
|
||||
throw new QueryParsingException(context.parseContext(), "Failed to parse", e);
|
||||
throw new ParsingException(context.parseContext(), "Failed to parse", e);
|
||||
} finally {
|
||||
if (type != null) {
|
||||
QueryShardContext.setTypes(previousTypes);
|
||||
|
@ -33,7 +33,7 @@ import java.io.IOException;
|
||||
public abstract class BaseQueryParser<QB extends QueryBuilder<QB>> implements QueryParser<QB> {
|
||||
|
||||
@Override
|
||||
public final Query parse(QueryShardContext context) throws IOException, QueryParsingException {
|
||||
public final Query parse(QueryShardContext context) throws IOException {
|
||||
return fromXContent(context.parseContext()).toQuery(context);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import java.io.IOException;
|
||||
public abstract class BaseQueryParserTemp implements QueryParser {
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
Query query = parse(parseContext.shardContext());
|
||||
return new QueryWrappingQueryBuilder(query);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@ -47,7 +48,7 @@ public class BoolQueryParser extends BaseQueryParser<BoolQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoolQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public BoolQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, ParsingException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
boolean disableCoord = BoolQueryBuilder.DISABLE_COORD_DEFAULT;
|
||||
@ -89,7 +90,7 @@ public class BoolQueryParser extends BaseQueryParser<BoolQueryBuilder> {
|
||||
mustNotClauses.add(query);
|
||||
break;
|
||||
default:
|
||||
throw new QueryParsingException(parseContext, "[bool] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[bool] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
@ -112,7 +113,7 @@ public class BoolQueryParser extends BaseQueryParser<BoolQueryBuilder> {
|
||||
mustNotClauses.add(query);
|
||||
break;
|
||||
default:
|
||||
throw new QueryParsingException(parseContext, "bool query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "bool query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
@ -129,7 +130,7 @@ public class BoolQueryParser extends BaseQueryParser<BoolQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[bool] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[bool] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -35,7 +36,7 @@ public class BoostingQueryParser extends BaseQueryParser<BoostingQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoostingQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public BoostingQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
QueryBuilder positiveQuery = null;
|
||||
@ -59,7 +60,7 @@ public class BoostingQueryParser extends BaseQueryParser<BoostingQueryBuilder> {
|
||||
negativeQuery = parseContext.parseInnerQueryBuilder();
|
||||
negativeQueryFound = true;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[boosting] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[boosting] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("negative_boost".equals(currentFieldName) || "negativeBoost".equals(currentFieldName)) {
|
||||
@ -69,19 +70,19 @@ public class BoostingQueryParser extends BaseQueryParser<BoostingQueryBuilder> {
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[boosting] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[boosting] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!positiveQueryFound) {
|
||||
throw new QueryParsingException(parseContext, "[boosting] query requires 'positive' query to be set'");
|
||||
throw new ParsingException(parseContext, "[boosting] query requires 'positive' query to be set'");
|
||||
}
|
||||
if (!negativeQueryFound) {
|
||||
throw new QueryParsingException(parseContext, "[boosting] query requires 'negative' query to be set'");
|
||||
throw new ParsingException(parseContext, "[boosting] query requires 'negative' query to be set'");
|
||||
}
|
||||
if (negativeBoost < 0) {
|
||||
throw new QueryParsingException(parseContext, "[boosting] query requires 'negative_boost' to be set to be a positive value'");
|
||||
throw new ParsingException(parseContext, "[boosting] query requires 'negative_boost' to be set to be a positive value'");
|
||||
}
|
||||
|
||||
BoostingQueryBuilder boostingQuery = new BoostingQueryBuilder(positiveQuery, negativeQuery);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -35,11 +36,11 @@ public class CommonTermsQueryParser extends BaseQueryParser<CommonTermsQueryBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonTermsQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public CommonTermsQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
if (token != XContentParser.Token.FIELD_NAME) {
|
||||
throw new QueryParsingException(parseContext, "[common] query malformed, no field");
|
||||
throw new ParsingException(parseContext, "[common] query malformed, no field");
|
||||
}
|
||||
String fieldName = parser.currentName();
|
||||
Object text = null;
|
||||
@ -70,13 +71,13 @@ public class CommonTermsQueryParser extends BaseQueryParser<CommonTermsQueryBuil
|
||||
} else if ("high_freq".equals(innerFieldName) || "highFreq".equals(innerFieldName)) {
|
||||
highFreqMinimumShouldMatch = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[common] query does not support [" + innerFieldName
|
||||
throw new ParsingException(parseContext, "[common] query does not support [" + innerFieldName
|
||||
+ "] for [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[common] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[common] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("query".equals(currentFieldName)) {
|
||||
@ -98,7 +99,7 @@ public class CommonTermsQueryParser extends BaseQueryParser<CommonTermsQueryBuil
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[common] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[common] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,14 +109,14 @@ public class CommonTermsQueryParser extends BaseQueryParser<CommonTermsQueryBuil
|
||||
// move to the next token
|
||||
token = parser.nextToken();
|
||||
if (token != XContentParser.Token.END_OBJECT) {
|
||||
throw new QueryParsingException(
|
||||
throw new ParsingException(
|
||||
parseContext,
|
||||
"[common] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?");
|
||||
}
|
||||
}
|
||||
|
||||
if (text == null) {
|
||||
throw new QueryParsingException(parseContext, "No text specified for text query");
|
||||
throw new ParsingException(parseContext, "No text specified for text query");
|
||||
}
|
||||
return new CommonTermsQueryBuilder(fieldName, text)
|
||||
.lowFreqMinimumShouldMatch(lowFreqMinimumShouldMatch)
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -38,7 +39,7 @@ public class ConstantScoreQueryParser extends BaseQueryParser<ConstantScoreQuery
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantScoreQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public ConstantScoreQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
QueryBuilder query = null;
|
||||
@ -58,7 +59,7 @@ public class ConstantScoreQueryParser extends BaseQueryParser<ConstantScoreQuery
|
||||
query = parseContext.parseInnerFilterToQueryBuilder();
|
||||
queryFound = true;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[constant_score] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[constant_score] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("_name".equals(currentFieldName)) {
|
||||
@ -66,12 +67,12 @@ public class ConstantScoreQueryParser extends BaseQueryParser<ConstantScoreQuery
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[constant_score] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[constant_score] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!queryFound) {
|
||||
throw new QueryParsingException(parseContext, "[constant_score] requires a 'filter' element");
|
||||
throw new ParsingException(parseContext, "[constant_score] requires a 'filter' element");
|
||||
}
|
||||
|
||||
ConstantScoreQueryBuilder constantScoreBuilder = new ConstantScoreQueryBuilder(query);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -38,7 +39,7 @@ public class DisMaxQueryParser extends BaseQueryParser<DisMaxQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisMaxQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public DisMaxQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
@ -59,7 +60,7 @@ public class DisMaxQueryParser extends BaseQueryParser<DisMaxQueryBuilder> {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
queries.add(query);
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[dis_max] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[dis_max] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||
if ("queries".equals(currentFieldName)) {
|
||||
@ -70,7 +71,7 @@ public class DisMaxQueryParser extends BaseQueryParser<DisMaxQueryBuilder> {
|
||||
token = parser.nextToken();
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[dis_max] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[dis_max] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else {
|
||||
if ("boost".equals(currentFieldName)) {
|
||||
@ -80,13 +81,13 @@ public class DisMaxQueryParser extends BaseQueryParser<DisMaxQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[dis_max] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[dis_max] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!queriesFound) {
|
||||
throw new QueryParsingException(parseContext, "[dis_max] requires 'queries' field");
|
||||
throw new ParsingException(parseContext, "[dis_max] requires 'queries' field");
|
||||
}
|
||||
|
||||
DisMaxQueryBuilder disMaxQuery = new DisMaxQueryBuilder();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -35,7 +36,7 @@ public class ExistsQueryParser extends BaseQueryParser<ExistsQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExistsQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public ExistsQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String fieldPattern = null;
|
||||
@ -55,13 +56,13 @@ public class ExistsQueryParser extends BaseQueryParser<ExistsQueryBuilder> {
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[exists] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[exists] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldPattern == null) {
|
||||
throw new QueryParsingException(parseContext, "exists must be provided with a [field]");
|
||||
throw new ParsingException(parseContext, "exists must be provided with a [field]");
|
||||
}
|
||||
|
||||
ExistsQueryBuilder builder = new ExistsQueryBuilder(fieldPattern);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -35,7 +36,7 @@ public class FieldMaskingSpanQueryParser extends BaseQueryParser<FieldMaskingSpa
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldMaskingSpanQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public FieldMaskingSpanQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
@ -53,11 +54,11 @@ public class FieldMaskingSpanQueryParser extends BaseQueryParser<FieldMaskingSpa
|
||||
if ("query".equals(currentFieldName)) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (!(query instanceof SpanQueryBuilder)) {
|
||||
throw new QueryParsingException(parseContext, "[field_masking_span] query must be of type span query");
|
||||
throw new ParsingException(parseContext, "[field_masking_span] query must be of type span query");
|
||||
}
|
||||
inner = (SpanQueryBuilder) query;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[field_masking_span] query does not support ["
|
||||
throw new ParsingException(parseContext, "[field_masking_span] query does not support ["
|
||||
+ currentFieldName + "]");
|
||||
}
|
||||
} else {
|
||||
@ -68,15 +69,15 @@ public class FieldMaskingSpanQueryParser extends BaseQueryParser<FieldMaskingSpa
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[field_masking_span] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[field_masking_span] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inner == null) {
|
||||
throw new QueryParsingException(parseContext, "field_masking_span must have [query] span query clause");
|
||||
throw new ParsingException(parseContext, "field_masking_span must have [query] span query clause");
|
||||
}
|
||||
if (field == null) {
|
||||
throw new QueryParsingException(parseContext, "field_masking_span must have [field] set for it");
|
||||
throw new ParsingException(parseContext, "field_masking_span must have [field] set for it");
|
||||
}
|
||||
|
||||
FieldMaskingSpanQueryBuilder queryBuilder = new FieldMaskingSpanQueryBuilder(inner, field);
|
||||
|
@ -231,7 +231,7 @@ public class FuzzyQueryBuilder extends AbstractQueryBuilder<FuzzyQueryBuilder> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query doToQuery(QueryShardContext context) throws QueryParsingException, IOException {
|
||||
public Query doToQuery(QueryShardContext context) throws IOException {
|
||||
Query query = null;
|
||||
if (rewrite == null && context.isFilter()) {
|
||||
rewrite = QueryParsers.CONSTANT_SCORE.getPreferredName();
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -37,12 +38,12 @@ public class FuzzyQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
if (token != XContentParser.Token.FIELD_NAME) {
|
||||
throw new QueryParsingException(parseContext, "[fuzzy] query malformed, no field");
|
||||
throw new ParsingException(parseContext, "[fuzzy] query malformed, no field");
|
||||
}
|
||||
|
||||
String fieldName = parser.currentName();
|
||||
@ -83,7 +84,7 @@ public class FuzzyQueryParser extends BaseQueryParser {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[fuzzy] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[fuzzy] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,7 +96,7 @@ public class FuzzyQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "no value specified for fuzzy query");
|
||||
throw new ParsingException(parseContext, "no value specified for fuzzy query");
|
||||
}
|
||||
return new FuzzyQueryBuilder(fieldName, value)
|
||||
.fuzziness(fuzziness)
|
||||
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.query;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.GeoUtils;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
@ -64,7 +65,7 @@ public class GeoBoundingBoxQueryParser extends BaseQueryParserTemp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(QueryShardContext context) throws IOException, QueryParsingException {
|
||||
public Query parse(QueryShardContext context) throws IOException {
|
||||
QueryParseContext parseContext = context.parseContext();
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
@ -149,7 +150,7 @@ public class GeoBoundingBoxQueryParser extends BaseQueryParserTemp {
|
||||
} else if ("ignore_malformed".equals(currentFieldName) && coerce == false) {
|
||||
ignoreMalformed = parser.booleanValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "failed to parse [{}] query. unexpected field [{}]", NAME, currentFieldName);
|
||||
throw new ParsingException(parseContext, "failed to parse [{}] query. unexpected field [{}]", NAME, currentFieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,16 +161,16 @@ public class GeoBoundingBoxQueryParser extends BaseQueryParserTemp {
|
||||
// validation was not available prior to 2.x, so to support bwc percolation queries we only ignore_malformed on 2.x created indexes
|
||||
if (!indexCreatedBeforeV2_0 && !ignoreMalformed) {
|
||||
if (topLeft.lat() > 90.0 || topLeft.lat() < -90.0) {
|
||||
throw new QueryParsingException(parseContext, "illegal latitude value [{}] for [{}]", topLeft.lat(), NAME);
|
||||
throw new ParsingException(parseContext, "illegal latitude value [{}] for [{}]", topLeft.lat(), NAME);
|
||||
}
|
||||
if (topLeft.lon() > 180.0 || topLeft.lon() < -180) {
|
||||
throw new QueryParsingException(parseContext, "illegal longitude value [{}] for [{}]", topLeft.lon(), NAME);
|
||||
throw new ParsingException(parseContext, "illegal longitude value [{}] for [{}]", topLeft.lon(), NAME);
|
||||
}
|
||||
if (bottomRight.lat() > 90.0 || bottomRight.lat() < -90.0) {
|
||||
throw new QueryParsingException(parseContext, "illegal latitude value [{}] for [{}]", bottomRight.lat(), NAME);
|
||||
throw new ParsingException(parseContext, "illegal latitude value [{}] for [{}]", bottomRight.lat(), NAME);
|
||||
}
|
||||
if (bottomRight.lon() > 180.0 || bottomRight.lon() < -180) {
|
||||
throw new QueryParsingException(parseContext, "illegal longitude value [{}] for [{}]", bottomRight.lon(), NAME);
|
||||
throw new ParsingException(parseContext, "illegal longitude value [{}] for [{}]", bottomRight.lon(), NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,10 +188,10 @@ public class GeoBoundingBoxQueryParser extends BaseQueryParserTemp {
|
||||
|
||||
MappedFieldType fieldType = context.fieldMapper(fieldName);
|
||||
if (fieldType == null) {
|
||||
throw new QueryParsingException(parseContext, "failed to parse [{}] query. could not find [{}] field [{}]", NAME, GeoPointFieldMapper.CONTENT_TYPE, fieldName);
|
||||
throw new ParsingException(parseContext, "failed to parse [{}] query. could not find [{}] field [{}]", NAME, GeoPointFieldMapper.CONTENT_TYPE, fieldName);
|
||||
}
|
||||
if (!(fieldType instanceof GeoPointFieldMapper.GeoPointFieldType)) {
|
||||
throw new QueryParsingException(parseContext, "failed to parse [{}] query. field [{}] is expected to be of type [{}], but is of [{}] type instead", NAME, fieldName, GeoPointFieldMapper.CONTENT_TYPE, fieldType.typeName());
|
||||
throw new ParsingException(parseContext, "failed to parse [{}] query. field [{}] is expected to be of type [{}], but is of [{}] type instead", NAME, fieldName, GeoPointFieldMapper.CONTENT_TYPE, fieldType.typeName());
|
||||
}
|
||||
GeoPointFieldMapper.GeoPointFieldType geoFieldType = ((GeoPointFieldMapper.GeoPointFieldType) fieldType);
|
||||
|
||||
@ -201,7 +202,7 @@ public class GeoBoundingBoxQueryParser extends BaseQueryParserTemp {
|
||||
IndexGeoPointFieldData indexFieldData = context.getForField(fieldType);
|
||||
filter = new InMemoryGeoBoundingBoxQuery(topLeft, bottomRight, indexFieldData);
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "failed to parse [{}] query. geo bounding box type [{}] is not supported. either [indexed] or [memory] are allowed", NAME, type);
|
||||
throw new ParsingException(parseContext, "failed to parse [{}] query. geo bounding box type [{}] is not supported. either [indexed] or [memory] are allowed", NAME, type);
|
||||
}
|
||||
if (filter != null) {
|
||||
filter.setBoost(boost);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.geo.GeoDistance;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.GeoUtils;
|
||||
@ -46,7 +47,7 @@ public class GeoDistanceQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
XContentParser.Token token;
|
||||
@ -86,7 +87,7 @@ public class GeoDistanceQueryParser extends BaseQueryParser {
|
||||
} else if (currentName.equals(GeoPointFieldMapper.Names.GEOHASH)) {
|
||||
point.resetFromGeoHash(parser.text());
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[geo_distance] query does not support [" + currentFieldName
|
||||
throw new ParsingException(parseContext, "[geo_distance] query does not support [" + currentFieldName
|
||||
+ "]");
|
||||
}
|
||||
}
|
||||
@ -132,7 +133,7 @@ public class GeoDistanceQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
if (vDistance == null) {
|
||||
throw new QueryParsingException(parseContext, "geo_distance requires 'distance' to be specified");
|
||||
throw new ParsingException(parseContext, "geo_distance requires 'distance' to be specified");
|
||||
}
|
||||
|
||||
GeoDistanceQueryBuilder qb = new GeoDistanceQueryBuilder(fieldName);
|
||||
|
@ -67,7 +67,7 @@ public class GeoDistanceRangeQueryParser extends BaseQueryParser<GeoDistanceRang
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeoDistanceRangeQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public GeoDistanceRangeQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
XContentParser.Token token;
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.GeoUtils;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
@ -54,7 +55,7 @@ public class GeoPolygonQueryParser extends BaseQueryParser<GeoPolygonQueryBuilde
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeoPolygonQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public GeoPolygonQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String fieldName = null;
|
||||
@ -86,11 +87,11 @@ public class GeoPolygonQueryParser extends BaseQueryParser<GeoPolygonQueryBuilde
|
||||
shell.add(GeoUtils.parseGeoPoint(parser));
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[geo_polygon] query does not support [" + currentFieldName
|
||||
throw new ParsingException(parseContext, "[geo_polygon] query does not support [" + currentFieldName
|
||||
+ "]");
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[geo_polygon] query does not support token type [" + token.name()
|
||||
throw new ParsingException(parseContext, "[geo_polygon] query does not support token type [" + token.name()
|
||||
+ "] under [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
@ -107,10 +108,10 @@ public class GeoPolygonQueryParser extends BaseQueryParser<GeoPolygonQueryBuilde
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, IGNORE_MALFORMED_FIELD)) {
|
||||
ignoreMalformed = parser.booleanValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[geo_polygon] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[geo_polygon] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[geo_polygon] unexpected token type [" + token.name() + "]");
|
||||
throw new ParsingException(parseContext, "[geo_polygon] unexpected token type [" + token.name() + "]");
|
||||
}
|
||||
}
|
||||
GeoPolygonQueryBuilder builder = new GeoPolygonQueryBuilder(fieldName, shell);
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.geo.ShapeRelation;
|
||||
@ -47,7 +48,7 @@ public class GeoShapeQueryParser extends BaseQueryParser<GeoShapeQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeoShapeQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public GeoShapeQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String fieldName = null;
|
||||
@ -82,12 +83,12 @@ public class GeoShapeQueryParser extends BaseQueryParser<GeoShapeQueryBuilder> {
|
||||
String strategyName = parser.text();
|
||||
strategy = SpatialStrategy.fromString(strategyName);
|
||||
if (strategy == null) {
|
||||
throw new QueryParsingException(parseContext, "Unknown strategy [" + strategyName + " ]");
|
||||
throw new ParsingException(parseContext, "Unknown strategy [" + strategyName + " ]");
|
||||
}
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, RELATION_FIELD)) {
|
||||
shapeRelation = ShapeRelation.getRelationByName(parser.text());
|
||||
if (shapeRelation == null) {
|
||||
throw new QueryParsingException(parseContext, "Unknown shape operation [" + parser.text() + " ]");
|
||||
throw new ParsingException(parseContext, "Unknown shape operation [" + parser.text() + " ]");
|
||||
}
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, INDEXED_SHAPE_FIELD)) {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
@ -106,7 +107,7 @@ public class GeoShapeQueryParser extends BaseQueryParser<GeoShapeQueryBuilder> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[geo_shape] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[geo_shape] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,7 +117,7 @@ public class GeoShapeQueryParser extends BaseQueryParser<GeoShapeQueryBuilder> {
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[geo_shape] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[geo_shape] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ public class GeohashCellQuery {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public Builder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String fieldName = null;
|
||||
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.support.QueryInnerHits;
|
||||
@ -40,7 +41,7 @@ public class HasChildQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
String childType = null;
|
||||
@ -63,7 +64,7 @@ public class HasChildQueryParser extends BaseQueryParser {
|
||||
} else if ("inner_hits".equals(currentFieldName)) {
|
||||
queryInnerHits = new QueryInnerHits(parser);
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[has_child] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[has_child] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("type".equals(currentFieldName) || "child_type".equals(currentFieldName) || "childType".equals(currentFieldName)) {
|
||||
@ -79,7 +80,7 @@ public class HasChildQueryParser extends BaseQueryParser {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[has_child] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[has_child] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
@ -123,7 +124,7 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
|
||||
innerQuery.setBoost(boost);
|
||||
DocumentMapper parentDocMapper = context.mapperService().documentMapper(type);
|
||||
if (parentDocMapper == null) {
|
||||
throw new QueryParsingException(context.parseContext(), "[has_parent] query configured 'parent_type' [" + type
|
||||
throw new ParsingException(context.parseContext(), "[has_parent] query configured 'parent_type' [" + type
|
||||
+ "] is not a valid type");
|
||||
}
|
||||
|
||||
@ -158,7 +159,7 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
|
||||
}
|
||||
}
|
||||
if (parentChildIndexFieldData == null) {
|
||||
throw new QueryParsingException(context.parseContext(), "[has_parent] no _parent field configured");
|
||||
throw new ParsingException(context.parseContext(), "[has_parent] no _parent field configured");
|
||||
}
|
||||
|
||||
Query parentTypeQuery = null;
|
||||
|
@ -20,6 +20,7 @@ package org.elasticsearch.index.query;
|
||||
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.support.QueryInnerHits;
|
||||
@ -39,7 +40,7 @@ public class HasParentQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
@ -60,7 +61,7 @@ public class HasParentQueryParser extends BaseQueryParser {
|
||||
} else if ("inner_hits".equals(currentFieldName)) {
|
||||
innerHits = new QueryInnerHits(parser);
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[has_parent] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[has_parent] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if (parseContext.parseFieldMatcher().match(currentFieldName, TYPE_FIELD)) {
|
||||
@ -72,7 +73,7 @@ public class HasParentQueryParser extends BaseQueryParser {
|
||||
} else if ("none".equals(scoreModeValue)) {
|
||||
score = false;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[has_parent] query does not support [" + scoreModeValue + "] as an option for score_mode");
|
||||
throw new ParsingException(parseContext, "[has_parent] query does not support [" + scoreModeValue + "] as an option for score_mode");
|
||||
}
|
||||
} else if ("score".equals(currentFieldName)) {
|
||||
score = parser.booleanValue();
|
||||
@ -81,7 +82,7 @@ public class HasParentQueryParser extends BaseQueryParser {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[has_parent] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[has_parent] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -61,11 +62,11 @@ public class IdsQueryParser extends BaseQueryParser<IdsQueryBuilder> {
|
||||
(token == XContentParser.Token.VALUE_NUMBER)) {
|
||||
String id = parser.textOrNull();
|
||||
if (id == null) {
|
||||
throw new QueryParsingException(parseContext, "No value specified for term filter");
|
||||
throw new ParsingException(parseContext, "No value specified for term filter");
|
||||
}
|
||||
ids.add(id);
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "Illegal value for id, expecting a string or number, got: "
|
||||
throw new ParsingException(parseContext, "Illegal value for id, expecting a string or number, got: "
|
||||
+ token);
|
||||
}
|
||||
}
|
||||
@ -73,12 +74,12 @@ public class IdsQueryParser extends BaseQueryParser<IdsQueryBuilder> {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
String value = parser.textOrNull();
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "No type specified for term filter");
|
||||
throw new ParsingException(parseContext, "No type specified for term filter");
|
||||
}
|
||||
types.add(value);
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[ids] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[ids] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("type".equals(currentFieldName) || "_type".equals(currentFieldName)) {
|
||||
@ -88,12 +89,12 @@ public class IdsQueryParser extends BaseQueryParser<IdsQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[ids] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[ids] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!idsProvided) {
|
||||
throw new QueryParsingException(parseContext, "[ids] query, no ids values provided");
|
||||
throw new ParsingException(parseContext, "[ids] query, no ids values provided");
|
||||
}
|
||||
|
||||
IdsQueryBuilder query = new IdsQueryBuilder(types.toArray(new String[types.size()]));
|
||||
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
@ -162,7 +163,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
||||
} catch (QueryShardException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new QueryParsingException(getShardContext().parseContext(), "Failed to parse", e);
|
||||
throw new ParsingException(getShardContext().parseContext(), "Failed to parse", e);
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parser.close();
|
||||
@ -182,7 +183,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
||||
} catch (QueryShardException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new QueryParsingException(getShardContext().parseContext(), "Failed to parse", e);
|
||||
throw new ParsingException(getShardContext().parseContext(), "Failed to parse", e);
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parser.close();
|
||||
@ -200,10 +201,10 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
||||
try {
|
||||
parser = XContentFactory.xContent(source).createParser(source);
|
||||
return innerParse(context, parser);
|
||||
} catch (QueryParsingException e) {
|
||||
} catch (ParsingException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new QueryParsingException(context.parseContext(), "Failed to parse", e);
|
||||
throw new ParsingException(context.parseContext(), "Failed to parse", e);
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parser.close();
|
||||
@ -211,15 +212,15 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public ParsedQuery parse(String source) throws QueryParsingException, QueryShardException {
|
||||
public ParsedQuery parse(String source) throws ParsingException, QueryShardException {
|
||||
XContentParser parser = null;
|
||||
try {
|
||||
parser = XContentFactory.xContent(source).createParser(source);
|
||||
return innerParse(cache.get(), parser);
|
||||
} catch (QueryShardException|QueryParsingException e) {
|
||||
} catch (QueryShardException|ParsingException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new QueryParsingException(getShardContext().parseContext(), "Failed to parse [" + source + "]", e);
|
||||
throw new ParsingException(getShardContext().parseContext(), "Failed to parse [" + source + "]", e);
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parser.close();
|
||||
@ -236,7 +237,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
||||
try {
|
||||
return innerParse(context, parser);
|
||||
} catch (IOException e) {
|
||||
throw new QueryParsingException(context.parseContext(), "Failed to parse", e);
|
||||
throw new ParsingException(context.parseContext(), "Failed to parse", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,7 +308,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
||||
XContentParser qSourceParser = XContentFactory.xContent(querySource).createParser(querySource);
|
||||
parsedQuery = parse(qSourceParser);
|
||||
} else {
|
||||
throw new QueryParsingException(getShardContext().parseContext(), "request does not support [" + fieldName + "]");
|
||||
throw new ParsingException(getShardContext().parseContext(), "request does not support [" + fieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -317,10 +318,10 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
||||
} catch (QueryShardException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
throw new QueryParsingException(getShardContext().parseContext(), "Failed to parse", e);
|
||||
throw new ParsingException(getShardContext().parseContext(), "Failed to parse", e);
|
||||
}
|
||||
|
||||
throw new QueryParsingException(getShardContext().parseContext(), "Required query is missing");
|
||||
throw new ParsingException(getShardContext().parseContext(), "Required query is missing");
|
||||
}
|
||||
|
||||
//norelease
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -41,7 +42,7 @@ public class IndicesQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, ParsingException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
QueryBuilder innerQuery = null;
|
||||
@ -62,27 +63,27 @@ public class IndicesQueryParser extends BaseQueryParser {
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, NO_MATCH_QUERY)) {
|
||||
noMatchQuery = parseContext.parseInnerQueryBuilder();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[indices] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[indices] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||
if ("indices".equals(currentFieldName)) {
|
||||
if (indices.isEmpty() == false) {
|
||||
throw new QueryParsingException(parseContext, "[indices] indices or index already specified");
|
||||
throw new ParsingException(parseContext, "[indices] indices or index already specified");
|
||||
}
|
||||
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
||||
String value = parser.textOrNull();
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "[indices] no value specified for 'indices' entry");
|
||||
throw new ParsingException(parseContext, "[indices] no value specified for 'indices' entry");
|
||||
}
|
||||
indices.add(value);
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[indices] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[indices] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("index".equals(currentFieldName)) {
|
||||
if (indices.isEmpty() == false) {
|
||||
throw new QueryParsingException(parseContext, "[indices] indices or index already specified");
|
||||
throw new ParsingException(parseContext, "[indices] indices or index already specified");
|
||||
}
|
||||
indices.add(parser.text());
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, NO_MATCH_QUERY)) {
|
||||
@ -92,16 +93,16 @@ public class IndicesQueryParser extends BaseQueryParser {
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[indices] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[indices] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (innerQuery == null) {
|
||||
throw new QueryParsingException(parseContext, "[indices] requires 'query' element");
|
||||
throw new ParsingException(parseContext, "[indices] requires 'query' element");
|
||||
}
|
||||
if (indices.isEmpty()) {
|
||||
throw new QueryParsingException(parseContext, "[indices] requires 'indices' or 'index' element");
|
||||
throw new ParsingException(parseContext, "[indices] requires 'indices' or 'index' element");
|
||||
}
|
||||
return new IndicesQueryBuilder(innerQuery, indices.toArray(new String[indices.size()]))
|
||||
.noMatchQuery(noMatchQuery)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -52,7 +53,7 @@ public class MatchAllQueryParser extends BaseQueryParser<MatchAllQueryBuilder> {
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[match_all] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[match_all] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -38,7 +39,7 @@ public class MatchNoneQueryParser extends BaseQueryParser {
|
||||
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
if (token != XContentParser.Token.END_OBJECT) {
|
||||
throw new QueryParsingException(parseContext, "[match_none] query malformed");
|
||||
throw new ParsingException(parseContext, "[match_none] query malformed");
|
||||
}
|
||||
|
||||
return new MatchNoneQueryBuilder();
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.FuzzyQuery;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -41,7 +42,7 @@ public class MatchQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public MatchQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
MatchQuery.Type type = MatchQuery.Type.BOOLEAN;
|
||||
@ -55,7 +56,7 @@ public class MatchQueryParser extends BaseQueryParser {
|
||||
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
if (token != XContentParser.Token.FIELD_NAME) {
|
||||
throw new QueryParsingException(parseContext, "[match] query malformed, no field");
|
||||
throw new ParsingException(parseContext, "[match] query malformed, no field");
|
||||
}
|
||||
String fieldName = parser.currentName();
|
||||
|
||||
@ -93,7 +94,7 @@ public class MatchQueryParser extends BaseQueryParser {
|
||||
} else if ("phrase_prefix".equals(tStr) || "phrasePrefix".equals(currentFieldName)) {
|
||||
type = MatchQuery.Type.PHRASE_PREFIX;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[match] query does not support type " + tStr);
|
||||
throw new ParsingException(parseContext, "[match] query does not support type " + tStr);
|
||||
}
|
||||
} else if ("analyzer".equals(currentFieldName)) {
|
||||
analyzer = parser.text();
|
||||
@ -126,12 +127,12 @@ public class MatchQueryParser extends BaseQueryParser {
|
||||
} else if ("all".equalsIgnoreCase(zeroTermsDocs)) {
|
||||
zeroTermsQuery = MatchQuery.ZeroTermsQuery.ALL;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "Unsupported zero_terms_docs value [" + zeroTermsDocs + "]");
|
||||
throw new ParsingException(parseContext, "Unsupported zero_terms_docs value [" + zeroTermsDocs + "]");
|
||||
}
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[match] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[match] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -141,13 +142,13 @@ public class MatchQueryParser extends BaseQueryParser {
|
||||
// move to the next token
|
||||
token = parser.nextToken();
|
||||
if (token != XContentParser.Token.END_OBJECT) {
|
||||
throw new QueryParsingException(parseContext,
|
||||
throw new ParsingException(parseContext,
|
||||
"[match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?");
|
||||
}
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "No text specified for text query");
|
||||
throw new ParsingException(parseContext, "No text specified for text query");
|
||||
}
|
||||
|
||||
MatchQueryBuilder matchQuery = new MatchQueryBuilder(fieldName, value);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -34,7 +35,7 @@ public class MissingQueryParser extends BaseQueryParser<MissingQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MissingQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public MissingQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String fieldPattern = null;
|
||||
@ -60,13 +61,13 @@ public class MissingQueryParser extends BaseQueryParser<MissingQueryBuilder> {
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[missing] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[missing] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldPattern == null) {
|
||||
throw new QueryParsingException(parseContext, "missing must be provided with a [field]");
|
||||
throw new ParsingException(parseContext, "missing must be provided with a [field]");
|
||||
}
|
||||
return new MissingQueryBuilder(fieldPattern, nullValue, existence)
|
||||
.boost(boost)
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.MoreLikeThisQueryBuilder.Item;
|
||||
|
||||
@ -61,7 +62,7 @@ public class MoreLikeThisQueryParser extends BaseQueryParser<MoreLikeThisQueryBu
|
||||
}
|
||||
|
||||
@Override
|
||||
public MoreLikeThisQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public MoreLikeThisQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
// document inputs
|
||||
@ -130,7 +131,7 @@ public class MoreLikeThisQueryParser extends BaseQueryParser<MoreLikeThisQueryBu
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[mlt] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[mlt] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||
if (parseContext.parseFieldMatcher().match(currentFieldName, Field.FIELDS)) {
|
||||
@ -166,7 +167,7 @@ public class MoreLikeThisQueryParser extends BaseQueryParser<MoreLikeThisQueryBu
|
||||
stopWords.add(parser.text());
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[mlt] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[mlt] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
if (parseContext.parseFieldMatcher().match(currentFieldName, Field.LIKE)) {
|
||||
@ -174,16 +175,16 @@ public class MoreLikeThisQueryParser extends BaseQueryParser<MoreLikeThisQueryBu
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, Field.UNLIKE)) {
|
||||
parseLikeField(parseContext, unlikeTexts, unlikeItems);
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[mlt] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[mlt] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (likeTexts.isEmpty() && likeItems.isEmpty()) {
|
||||
throw new QueryParsingException(parseContext, "more_like_this requires 'like' to be specified");
|
||||
throw new ParsingException(parseContext, "more_like_this requires 'like' to be specified");
|
||||
}
|
||||
if (fields != null && fields.isEmpty()) {
|
||||
throw new QueryParsingException(parseContext, "more_like_this requires 'fields' to be non-empty");
|
||||
throw new ParsingException(parseContext, "more_like_this requires 'fields' to be non-empty");
|
||||
}
|
||||
|
||||
MoreLikeThisQueryBuilder moreLikeThisQueryBuilder = new MoreLikeThisQueryBuilder(fields)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.search.MatchQuery;
|
||||
@ -40,7 +41,7 @@ public class MultiMatchQueryParser extends BaseQueryParser<MultiMatchQueryBuilde
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiMatchQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public MultiMatchQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
Object value = null;
|
||||
@ -76,7 +77,7 @@ public class MultiMatchQueryParser extends BaseQueryParser<MultiMatchQueryBuilde
|
||||
} else if (token.isValue()) {
|
||||
parseFieldAndBoost(parser, fieldsBoosts);
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[" + MultiMatchQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[" + MultiMatchQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("query".equals(currentFieldName)) {
|
||||
@ -116,22 +117,22 @@ public class MultiMatchQueryParser extends BaseQueryParser<MultiMatchQueryBuilde
|
||||
} else if ("all".equalsIgnoreCase(zeroTermsDocs)) {
|
||||
zeroTermsQuery = MatchQuery.ZeroTermsQuery.ALL;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "Unsupported zero_terms_docs value [" + zeroTermsDocs + "]");
|
||||
throw new ParsingException(parseContext, "Unsupported zero_terms_docs value [" + zeroTermsDocs + "]");
|
||||
}
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[match] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[match] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "No text specified for multi_match query");
|
||||
throw new ParsingException(parseContext, "No text specified for multi_match query");
|
||||
}
|
||||
|
||||
if (fieldsBoosts.isEmpty()) {
|
||||
throw new QueryParsingException(parseContext, "No fields specified for multi_match query");
|
||||
throw new ParsingException(parseContext, "No fields specified for multi_match query");
|
||||
}
|
||||
|
||||
return new MultiMatchQueryBuilder(value)
|
||||
|
@ -25,6 +25,7 @@ import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
@ -48,7 +49,7 @@ public class NestedQueryParser extends BaseQueryParser<NestedQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NestedQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public NestedQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
ScoreMode scoreMode = NestedQueryBuilder.DEFAULT_SCORE_MODE;
|
||||
@ -69,7 +70,7 @@ public class NestedQueryParser extends BaseQueryParser<NestedQueryBuilder> {
|
||||
} else if ("inner_hits".equals(currentFieldName)) {
|
||||
queryInnerHits = new QueryInnerHits(parser);
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[nested] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[nested] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("path".equals(currentFieldName)) {
|
||||
@ -89,12 +90,12 @@ public class NestedQueryParser extends BaseQueryParser<NestedQueryBuilder> {
|
||||
} else if ("none".equals(sScoreMode)) {
|
||||
scoreMode = ScoreMode.None;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "illegal score_mode for nested query [" + sScoreMode + "]");
|
||||
throw new ParsingException(parseContext, "illegal score_mode for nested query [" + sScoreMode + "]");
|
||||
}
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[nested] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[nested] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -38,7 +39,7 @@ public class NotQueryParser extends BaseQueryParser<NotQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public NotQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
QueryBuilder query = null;
|
||||
@ -68,13 +69,13 @@ public class NotQueryParser extends BaseQueryParser<NotQueryBuilder> {
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[not] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[not] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!queryFound) {
|
||||
throw new QueryParsingException(parseContext, "query is required when using `not` query");
|
||||
throw new ParsingException(parseContext, "query is required when using `not` query");
|
||||
}
|
||||
|
||||
NotQueryBuilder notQueryBuilder = new NotQueryBuilder(query);
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -38,7 +39,7 @@ public class PrefixQueryParser extends BaseQueryParser<PrefixQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrefixQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public PrefixQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String fieldName = parser.currentName();
|
||||
@ -69,7 +70,7 @@ public class PrefixQueryParser extends BaseQueryParser<PrefixQueryBuilder> {
|
||||
} else if ("rewrite".equals(currentFieldName)) {
|
||||
rewrite = parser.textOrNull();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[regexp] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[regexp] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,7 +85,7 @@ public class PrefixQueryParser extends BaseQueryParser<PrefixQueryBuilder> {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "No value specified for prefix query");
|
||||
throw new ParsingException(parseContext, "No value specified for prefix query");
|
||||
}
|
||||
return new PrefixQueryBuilder(fieldName, value)
|
||||
.rewrite(rewrite)
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@ -35,7 +37,7 @@ public class QueryFilterParser extends BaseQueryParser<QueryFilterBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryFilterBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryFilterBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
return new QueryFilterBuilder(parseContext.parseInnerQueryBuilder());
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
||||
@ -124,7 +125,7 @@ public class QueryParseContext {
|
||||
if (parser.currentToken() != XContentParser.Token.START_OBJECT) {
|
||||
token = parser.nextToken();
|
||||
if (token != XContentParser.Token.START_OBJECT) {
|
||||
throw new QueryParsingException(this, "[_na] query malformed, must start with start_object");
|
||||
throw new ParsingException(this, "[_na] query malformed, must start with start_object");
|
||||
}
|
||||
}
|
||||
token = parser.nextToken();
|
||||
@ -133,18 +134,18 @@ public class QueryParseContext {
|
||||
return EmptyQueryBuilder.PROTOTYPE;
|
||||
}
|
||||
if (token != XContentParser.Token.FIELD_NAME) {
|
||||
throw new QueryParsingException(this, "[_na] query malformed, no field after start_object");
|
||||
throw new ParsingException(this, "[_na] query malformed, no field after start_object");
|
||||
}
|
||||
String queryName = parser.currentName();
|
||||
// move to the next START_OBJECT
|
||||
token = parser.nextToken();
|
||||
if (token != XContentParser.Token.START_OBJECT && token != XContentParser.Token.START_ARRAY) {
|
||||
throw new QueryParsingException(this, "[_na] query malformed, no field after start_object");
|
||||
throw new ParsingException(this, "[_na] query malformed, no field after start_object");
|
||||
}
|
||||
|
||||
QueryParser queryParser = queryParser(queryName);
|
||||
if (queryParser == null) {
|
||||
throw new QueryParsingException(this, "No query registered for [" + queryName + "]");
|
||||
throw new ParsingException(this, "No query registered for [" + queryName + "]");
|
||||
}
|
||||
QueryBuilder result = queryParser.fromXContent(this);
|
||||
if (parser.currentToken() == XContentParser.Token.END_OBJECT || parser.currentToken() == XContentParser.Token.END_ARRAY) {
|
||||
@ -171,13 +172,13 @@ public class QueryParseContext {
|
||||
}
|
||||
|
||||
//norelease setting and checking the isFilter Flag should completely be moved to toQuery/toFilter after query refactoring
|
||||
public QueryBuilder parseInnerFilterToQueryBuilder(String queryName) throws IOException, QueryParsingException {
|
||||
public QueryBuilder parseInnerFilterToQueryBuilder(String queryName) throws IOException {
|
||||
final boolean originalIsFilter = this.shardContext.isFilter;
|
||||
try {
|
||||
this.shardContext.isFilter = true;
|
||||
QueryParser queryParser = queryParser(queryName);
|
||||
if (queryParser == null) {
|
||||
throw new QueryParsingException(this, "No query registered for [" + queryName + "]");
|
||||
throw new ParsingException(this, "No query registered for [" + queryName + "]");
|
||||
}
|
||||
return queryParser.fromXContent(this);
|
||||
} finally {
|
||||
|
@ -45,7 +45,7 @@ public interface QueryParser<QB extends QueryBuilder<QB>> {
|
||||
*/
|
||||
//norelease can be removed in favour of fromXContent once search requests can be parsed on the coordinating node
|
||||
@Nullable
|
||||
Query parse(QueryShardContext context) throws IOException, QueryParsingException;
|
||||
Query parse(QueryShardContext context) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a new {@link QueryBuilder} from the query held by the {@link QueryShardContext}
|
||||
@ -57,9 +57,8 @@ public interface QueryParser<QB extends QueryBuilder<QB>> {
|
||||
* call
|
||||
* @return the new QueryBuilder
|
||||
* @throws IOException
|
||||
* @throws QueryParsingException
|
||||
*/
|
||||
QB fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException;
|
||||
QB fromXContent(QueryParseContext parseContext) throws IOException;
|
||||
|
||||
/**
|
||||
* @return an empty {@link QueryBuilder} instance for this parser that can be used for deserialization
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
@ -43,7 +44,7 @@ public class QueryStringQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
String currentFieldName = null;
|
||||
XContentParser.Token token;
|
||||
@ -99,7 +100,7 @@ public class QueryStringQueryParser extends BaseQueryParser {
|
||||
fieldsAndWeights.put(fField, fBoost);
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[query_string] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[query_string] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("query".equals(currentFieldName)) {
|
||||
@ -157,17 +158,17 @@ public class QueryStringQueryParser extends BaseQueryParser {
|
||||
try {
|
||||
timeZone = parser.text();
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new QueryParsingException(parseContext, "[query_string] time_zone [" + parser.text() + "] is unknown");
|
||||
throw new ParsingException(parseContext, "[query_string] time_zone [" + parser.text() + "] is unknown");
|
||||
}
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[query_string] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[query_string] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (queryString == null) {
|
||||
throw new QueryParsingException(parseContext, "query_string must be provided with a [query]");
|
||||
throw new ParsingException(parseContext, "query_string must be provided with a [query]");
|
||||
}
|
||||
|
||||
QueryStringQueryBuilder queryStringQuery = new QueryStringQueryBuilder(queryString);
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -38,7 +39,7 @@ public class RangeQueryParser extends BaseQueryParser<RangeQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RangeQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public RangeQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String fieldName = null;
|
||||
@ -93,7 +94,7 @@ public class RangeQueryParser extends BaseQueryParser<RangeQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[range] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[range] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,7 +104,7 @@ public class RangeQueryParser extends BaseQueryParser<RangeQueryBuilder> {
|
||||
} else if (parseContext.parseFieldMatcher().match(currentFieldName, FIELDDATA_FIELD)) {
|
||||
// ignore
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[range] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[range] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -38,7 +39,7 @@ public class RegexpQueryParser extends BaseQueryParser<RegexpQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegexpQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public RegexpQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String fieldName = parser.currentName();
|
||||
@ -78,7 +79,7 @@ public class RegexpQueryParser extends BaseQueryParser<RegexpQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[regexp] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[regexp] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,7 +94,7 @@ public class RegexpQueryParser extends BaseQueryParser<RegexpQueryBuilder> {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "No value specified for regexp query");
|
||||
throw new ParsingException(parseContext, "No value specified for regexp query");
|
||||
}
|
||||
return new RegexpQueryBuilder(fieldName, value)
|
||||
.flags(flagsValue)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.script.Script;
|
||||
@ -41,7 +42,7 @@ public class ScriptQueryParser extends BaseQueryParser<ScriptQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public ScriptQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
ScriptParameterParser scriptParameterParser = new ScriptParameterParser();
|
||||
|
||||
@ -65,7 +66,7 @@ public class ScriptQueryParser extends BaseQueryParser<ScriptQueryBuilder> {
|
||||
} else if ("params".equals(currentFieldName)) { // TODO remove in 3.0 (here to support old script APIs)
|
||||
params = parser.map();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[script] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[script] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("_name".equals(currentFieldName)) {
|
||||
@ -73,7 +74,7 @@ public class ScriptQueryParser extends BaseQueryParser<ScriptQueryBuilder> {
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else if (!scriptParameterParser.token(currentFieldName, token, parser, parseContext.parseFieldMatcher())) {
|
||||
throw new QueryParsingException(parseContext, "[script] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[script] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,11 +88,11 @@ public class ScriptQueryParser extends BaseQueryParser<ScriptQueryBuilder> {
|
||||
script = new Script(scriptValue.script(), scriptValue.scriptType(), scriptParameterParser.lang(), params);
|
||||
}
|
||||
} else if (params != null) {
|
||||
throw new QueryParsingException(parseContext, "script params must be specified inside script object in a [script] filter");
|
||||
throw new ParsingException(parseContext, "script params must be specified inside script object in a [script] filter");
|
||||
}
|
||||
|
||||
if (script == null) {
|
||||
throw new QueryParsingException(parseContext, "script must be provided with a [script] filter");
|
||||
throw new ParsingException(parseContext, "script must be provided with a [script] filter");
|
||||
}
|
||||
|
||||
return new ScriptQueryBuilder(script)
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -68,7 +69,7 @@ public class SimpleQueryStringParser extends BaseQueryParser<SimpleQueryStringBu
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleQueryStringBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public SimpleQueryStringBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String currentFieldName = null;
|
||||
@ -110,7 +111,7 @@ public class SimpleQueryStringParser extends BaseQueryParser<SimpleQueryStringBu
|
||||
fieldsAndWeights.put(fField, fBoost);
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[" + SimpleQueryStringBuilder.NAME + "] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[" + SimpleQueryStringBuilder.NAME + "] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("query".equals(currentFieldName)) {
|
||||
@ -146,14 +147,14 @@ public class SimpleQueryStringParser extends BaseQueryParser<SimpleQueryStringBu
|
||||
} else if ("minimum_should_match".equals(currentFieldName)) {
|
||||
minimumShouldMatch = parser.textOrNull();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[" + SimpleQueryStringBuilder.NAME + "] unsupported field [" + parser.currentName() + "]");
|
||||
throw new ParsingException(parseContext, "[" + SimpleQueryStringBuilder.NAME + "] unsupported field [" + parser.currentName() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Query text is required
|
||||
if (queryBody == null) {
|
||||
throw new QueryParsingException(parseContext, "[" + SimpleQueryStringBuilder.NAME + "] query text missing");
|
||||
throw new ParsingException(parseContext, "[" + SimpleQueryStringBuilder.NAME + "] query text missing");
|
||||
}
|
||||
|
||||
SimpleQueryStringBuilder qb = new SimpleQueryStringBuilder(queryBody);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -36,7 +37,7 @@ public class SpanContainingQueryParser extends BaseQueryParser<SpanContainingQue
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanContainingQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public SpanContainingQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
String queryName = null;
|
||||
@ -52,24 +53,24 @@ public class SpanContainingQueryParser extends BaseQueryParser<SpanContainingQue
|
||||
if ("big".equals(currentFieldName)) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (!(query instanceof SpanQueryBuilder<?>)) {
|
||||
throw new QueryParsingException(parseContext, "span_containing [big] must be of type span query");
|
||||
throw new ParsingException(parseContext, "span_containing [big] must be of type span query");
|
||||
}
|
||||
big = (SpanQueryBuilder<?>) query;
|
||||
} else if ("little".equals(currentFieldName)) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (!(query instanceof SpanQueryBuilder<?>)) {
|
||||
throw new QueryParsingException(parseContext, "span_containing [little] must be of type span query");
|
||||
throw new ParsingException(parseContext, "span_containing [little] must be of type span query");
|
||||
}
|
||||
little = (SpanQueryBuilder<?>) query;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_containing] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_containing] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_containing] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_containing] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -36,7 +37,7 @@ public class SpanFirstQueryParser extends BaseQueryParser<SpanFirstQueryBuilder>
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanFirstQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public SpanFirstQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
@ -54,11 +55,11 @@ public class SpanFirstQueryParser extends BaseQueryParser<SpanFirstQueryBuilder>
|
||||
if ("match".equals(currentFieldName)) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (!(query instanceof SpanQueryBuilder)) {
|
||||
throw new QueryParsingException(parseContext, "spanFirst [match] must be of type span query");
|
||||
throw new ParsingException(parseContext, "spanFirst [match] must be of type span query");
|
||||
}
|
||||
match = (SpanQueryBuilder) query;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_first] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_first] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else {
|
||||
if ("boost".equals(currentFieldName)) {
|
||||
@ -68,15 +69,15 @@ public class SpanFirstQueryParser extends BaseQueryParser<SpanFirstQueryBuilder>
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_first] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_first] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match == null) {
|
||||
throw new QueryParsingException(parseContext, "spanFirst must have [match] span query clause");
|
||||
throw new ParsingException(parseContext, "spanFirst must have [match] span query clause");
|
||||
}
|
||||
if (end == null) {
|
||||
throw new QueryParsingException(parseContext, "spanFirst must have [end] set for it");
|
||||
throw new ParsingException(parseContext, "spanFirst must have [end] set for it");
|
||||
}
|
||||
SpanFirstQueryBuilder queryBuilder = new SpanFirstQueryBuilder(match, end);
|
||||
queryBuilder.boost(boost).queryName(queryName);
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -37,7 +38,7 @@ public class SpanMultiTermQueryParser extends BaseQueryParser<SpanMultiTermQuery
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanMultiTermQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public SpanMultiTermQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
String currentFieldName = null;
|
||||
MultiTermQueryBuilder subQuery = null;
|
||||
@ -51,11 +52,11 @@ public class SpanMultiTermQueryParser extends BaseQueryParser<SpanMultiTermQuery
|
||||
if (MATCH_NAME.equals(currentFieldName)) {
|
||||
QueryBuilder innerQuery = parseContext.parseInnerQueryBuilder();
|
||||
if (innerQuery instanceof MultiTermQueryBuilder == false) {
|
||||
throw new QueryParsingException(parseContext, "[span_multi] [" + MATCH_NAME + "] must be of type multi term query");
|
||||
throw new ParsingException(parseContext, "[span_multi] [" + MATCH_NAME + "] must be of type multi term query");
|
||||
}
|
||||
subQuery = (MultiTermQueryBuilder) innerQuery;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_multi] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_multi] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("_name".equals(currentFieldName)) {
|
||||
@ -63,13 +64,13 @@ public class SpanMultiTermQueryParser extends BaseQueryParser<SpanMultiTermQuery
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_multi] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_multi] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (subQuery == null) {
|
||||
throw new QueryParsingException(parseContext, "[span_multi] must have [" + MATCH_NAME + "] multi term query clause");
|
||||
throw new ParsingException(parseContext, "[span_multi] must have [" + MATCH_NAME + "] multi term query clause");
|
||||
}
|
||||
|
||||
return new SpanMultiTermQueryBuilder(subQuery).queryName(queryName).boost(boost);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -37,7 +38,7 @@ public class SpanNearQueryParser extends BaseQueryParser<SpanNearQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanNearQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public SpanNearQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
@ -58,12 +59,12 @@ public class SpanNearQueryParser extends BaseQueryParser<SpanNearQueryBuilder> {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (!(query instanceof SpanQueryBuilder)) {
|
||||
throw new QueryParsingException(parseContext, "spanNear [clauses] must be of type span query");
|
||||
throw new ParsingException(parseContext, "spanNear [clauses] must be of type span query");
|
||||
}
|
||||
clauses.add((SpanQueryBuilder) query);
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_near] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_near] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("in_order".equals(currentFieldName) || "inOrder".equals(currentFieldName)) {
|
||||
@ -77,19 +78,19 @@ public class SpanNearQueryParser extends BaseQueryParser<SpanNearQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_near] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_near] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_near] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_near] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
|
||||
if (clauses.isEmpty()) {
|
||||
throw new QueryParsingException(parseContext, "span_near must include [clauses]");
|
||||
throw new ParsingException(parseContext, "span_near must include [clauses]");
|
||||
}
|
||||
|
||||
if (slop == null) {
|
||||
throw new QueryParsingException(parseContext, "span_near must include [slop]");
|
||||
throw new ParsingException(parseContext, "span_near must include [slop]");
|
||||
}
|
||||
|
||||
SpanNearQueryBuilder queryBuilder = new SpanNearQueryBuilder(clauses.get(0), slop);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -36,7 +37,7 @@ public class SpanNotQueryParser extends BaseQueryParser<SpanNotQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanNotQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public SpanNotQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
@ -59,17 +60,17 @@ public class SpanNotQueryParser extends BaseQueryParser<SpanNotQueryBuilder> {
|
||||
if ("include".equals(currentFieldName)) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (!(query instanceof SpanQueryBuilder)) {
|
||||
throw new QueryParsingException(parseContext, "spanNot [include] must be of type span query");
|
||||
throw new ParsingException(parseContext, "spanNot [include] must be of type span query");
|
||||
}
|
||||
include = (SpanQueryBuilder) query;
|
||||
} else if ("exclude".equals(currentFieldName)) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (!(query instanceof SpanQueryBuilder)) {
|
||||
throw new QueryParsingException(parseContext, "spanNot [exclude] must be of type span query");
|
||||
throw new ParsingException(parseContext, "spanNot [exclude] must be of type span query");
|
||||
}
|
||||
exclude = (SpanQueryBuilder) query;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_not] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_not] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else {
|
||||
if ("dist".equals(currentFieldName)) {
|
||||
@ -83,18 +84,18 @@ public class SpanNotQueryParser extends BaseQueryParser<SpanNotQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_not] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_not] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (include == null) {
|
||||
throw new QueryParsingException(parseContext, "spanNot must have [include] span query clause");
|
||||
throw new ParsingException(parseContext, "spanNot must have [include] span query clause");
|
||||
}
|
||||
if (exclude == null) {
|
||||
throw new QueryParsingException(parseContext, "spanNot must have [exclude] span query clause");
|
||||
throw new ParsingException(parseContext, "spanNot must have [exclude] span query clause");
|
||||
}
|
||||
if (dist != null && (pre != null || post != null)) {
|
||||
throw new QueryParsingException(parseContext, "spanNot can either use [dist] or [pre] & [post] (or none)");
|
||||
throw new ParsingException(parseContext, "spanNot can either use [dist] or [pre] & [post] (or none)");
|
||||
}
|
||||
|
||||
SpanNotQueryBuilder spanNotQuery = new SpanNotQueryBuilder(include, exclude);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -37,7 +38,7 @@ public class SpanOrQueryParser extends BaseQueryParser<SpanOrQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanOrQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public SpanOrQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
@ -55,12 +56,12 @@ public class SpanOrQueryParser extends BaseQueryParser<SpanOrQueryBuilder> {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (!(query instanceof SpanQueryBuilder)) {
|
||||
throw new QueryParsingException(parseContext, "spanOr [clauses] must be of type span query");
|
||||
throw new ParsingException(parseContext, "spanOr [clauses] must be of type span query");
|
||||
}
|
||||
clauses.add((SpanQueryBuilder) query);
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_or] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_or] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else {
|
||||
if ("boost".equals(currentFieldName)) {
|
||||
@ -68,13 +69,13 @@ public class SpanOrQueryParser extends BaseQueryParser<SpanOrQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_or] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_or] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (clauses.isEmpty()) {
|
||||
throw new QueryParsingException(parseContext, "spanOr must include [clauses]");
|
||||
throw new ParsingException(parseContext, "spanOr must include [clauses]");
|
||||
}
|
||||
|
||||
SpanOrQueryBuilder queryBuilder = new SpanOrQueryBuilder(clauses.get(0));
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -36,7 +37,7 @@ public class SpanTermQueryParser extends BaseQueryParser<SpanTermQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanTermQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public SpanTermQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, ParsingException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
XContentParser.Token token = parser.currentToken();
|
||||
@ -67,7 +68,7 @@ public class SpanTermQueryParser extends BaseQueryParser<SpanTermQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_term] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_term] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,7 +80,7 @@ public class SpanTermQueryParser extends BaseQueryParser<SpanTermQueryBuilder> {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "No value specified for term query");
|
||||
throw new ParsingException(parseContext, "No value specified for term query");
|
||||
}
|
||||
|
||||
SpanTermQueryBuilder result = new SpanTermQueryBuilder(fieldName, value);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -35,7 +36,7 @@ public class SpanWithinQueryParser extends BaseQueryParser<SpanWithinQueryBuilde
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanWithinQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public SpanWithinQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
|
||||
@ -52,32 +53,32 @@ public class SpanWithinQueryParser extends BaseQueryParser<SpanWithinQueryBuilde
|
||||
if ("big".equals(currentFieldName)) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (query instanceof SpanQueryBuilder == false) {
|
||||
throw new QueryParsingException(parseContext, "span_within [big] must be of type span query");
|
||||
throw new ParsingException(parseContext, "span_within [big] must be of type span query");
|
||||
}
|
||||
big = (SpanQueryBuilder) query;
|
||||
} else if ("little".equals(currentFieldName)) {
|
||||
QueryBuilder query = parseContext.parseInnerQueryBuilder();
|
||||
if (query instanceof SpanQueryBuilder == false) {
|
||||
throw new QueryParsingException(parseContext, "span_within [little] must be of type span query");
|
||||
throw new ParsingException(parseContext, "span_within [little] must be of type span query");
|
||||
}
|
||||
little = (SpanQueryBuilder) query;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_within] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_within] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[span_within] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[span_within] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
|
||||
if (big == null) {
|
||||
throw new QueryParsingException(parseContext, "span_within must include [big]");
|
||||
throw new ParsingException(parseContext, "span_within must include [big]");
|
||||
}
|
||||
if (little == null) {
|
||||
throw new QueryParsingException(parseContext, "span_within must include [little]");
|
||||
throw new ParsingException(parseContext, "span_within must include [little]");
|
||||
}
|
||||
|
||||
SpanWithinQueryBuilder query = new SpanWithinQueryBuilder(big, little);
|
||||
|
@ -20,6 +20,7 @@ package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.script.Template;
|
||||
@ -55,7 +56,7 @@ public class TemplateQueryParser extends BaseQueryParser<TemplateQueryBuilder> {
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public TemplateQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public TemplateQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
Template template = parse(parser, parseContext.parseFieldMatcher());
|
||||
return new TemplateQueryBuilder(template);
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -39,7 +40,7 @@ public class TermQueryParser extends BaseQueryParser<TermQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TermQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public TermQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String queryName = null;
|
||||
@ -56,7 +57,7 @@ public class TermQueryParser extends BaseQueryParser<TermQueryBuilder> {
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
// also support a format of "term" : {"field_name" : { ... }}
|
||||
if (fieldName != null) {
|
||||
throw new QueryParsingException(parseContext, "[term] query does not support different field names, use [bool] query instead");
|
||||
throw new ParsingException(parseContext, "[term] query does not support different field names, use [bool] query instead");
|
||||
}
|
||||
fieldName = currentFieldName;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
@ -72,7 +73,7 @@ public class TermQueryParser extends BaseQueryParser<TermQueryBuilder> {
|
||||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[term] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[term] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -83,13 +84,13 @@ public class TermQueryParser extends BaseQueryParser<TermQueryBuilder> {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
if (fieldName != null) {
|
||||
throw new QueryParsingException(parseContext, "[term] query does not support different field names, use [bool] query instead");
|
||||
throw new ParsingException(parseContext, "[term] query does not support different field names, use [bool] query instead");
|
||||
}
|
||||
fieldName = currentFieldName;
|
||||
value = parser.objectBytes();
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||
throw new QueryParsingException(parseContext, "[term] query does not support array of values");
|
||||
throw new ParsingException(parseContext, "[term] query does not support array of values");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.indices.cache.query.terms.TermsLookup;
|
||||
@ -49,7 +50,7 @@ public class TermsQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
String fieldName = null;
|
||||
@ -70,7 +71,7 @@ public class TermsQueryParser extends BaseQueryParser {
|
||||
// skip
|
||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||
if (fieldName != null) {
|
||||
throw new QueryParsingException(parseContext, "[terms] query does not support multiple fields");
|
||||
throw new ParsingException(parseContext, "[terms] query does not support multiple fields");
|
||||
}
|
||||
fieldName = currentFieldName;
|
||||
values = parseValues(parseContext, parser);
|
||||
@ -92,13 +93,13 @@ public class TermsQueryParser extends BaseQueryParser {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[terms] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[terms] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldName == null) {
|
||||
throw new QueryParsingException(parseContext, "terms query requires a field name, followed by array of terms or a document lookup specification");
|
||||
throw new ParsingException(parseContext, "terms query requires a field name, followed by array of terms or a document lookup specification");
|
||||
}
|
||||
return new TermsQueryBuilder(fieldName, values, minShouldMatch, disableCoord, termsLookup)
|
||||
.boost(boost)
|
||||
@ -111,7 +112,7 @@ public class TermsQueryParser extends BaseQueryParser {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||
Object value = parser.objectBytes();
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "No value specified for terms query");
|
||||
throw new ParsingException(parseContext, "No value specified for terms query");
|
||||
}
|
||||
values.add(value);
|
||||
}
|
||||
@ -137,19 +138,19 @@ public class TermsQueryParser extends BaseQueryParser {
|
||||
} else if ("path".equals(currentFieldName)) {
|
||||
termsLookup.path(parser.text());
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[terms] query does not support [" + currentFieldName
|
||||
throw new ParsingException(parseContext, "[terms] query does not support [" + currentFieldName
|
||||
+ "] within lookup element");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (termsLookup.type() == null) {
|
||||
throw new QueryParsingException(parseContext, "[terms] query lookup element requires specifying the type");
|
||||
throw new ParsingException(parseContext, "[terms] query lookup element requires specifying the type");
|
||||
}
|
||||
if (termsLookup.id() == null) {
|
||||
throw new QueryParsingException(parseContext, "[terms] query lookup element requires specifying the id");
|
||||
throw new ParsingException(parseContext, "[terms] query lookup element requires specifying the id");
|
||||
}
|
||||
if (termsLookup.path() == null) {
|
||||
throw new QueryParsingException(parseContext, "[terms] query lookup element requires specifying the path");
|
||||
throw new ParsingException(parseContext, "[terms] query lookup element requires specifying the path");
|
||||
}
|
||||
return termsLookup;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -36,7 +37,7 @@ public class TypeQueryParser extends BaseQueryParser<TypeQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public TypeQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
BytesRef type = null;
|
||||
|
||||
@ -57,12 +58,12 @@ public class TypeQueryParser extends BaseQueryParser<TypeQueryBuilder> {
|
||||
type = parser.utf8Bytes();
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[type] filter doesn't support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[type] filter doesn't support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
throw new QueryParsingException(parseContext, "[type] filter needs to be provided with a value for the type");
|
||||
throw new ParsingException(parseContext, "[type] filter needs to be provided with a value for the type");
|
||||
}
|
||||
return new TypeQueryBuilder(type)
|
||||
.boost(boost)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -35,12 +36,12 @@ public class WildcardQueryParser extends BaseQueryParser<WildcardQueryBuilder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WildcardQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public WildcardQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
if (token != XContentParser.Token.FIELD_NAME) {
|
||||
throw new QueryParsingException(parseContext, "[wildcard] query malformed, no field");
|
||||
throw new ParsingException(parseContext, "[wildcard] query malformed, no field");
|
||||
}
|
||||
String fieldName = parser.currentName();
|
||||
String rewrite = null;
|
||||
@ -66,7 +67,7 @@ public class WildcardQueryParser extends BaseQueryParser<WildcardQueryBuilder> {
|
||||
} else if ("_name".equals(currentFieldName)) {
|
||||
queryName = parser.text();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "[wildcard] query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, "[wildcard] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -77,7 +78,7 @@ public class WildcardQueryParser extends BaseQueryParser<WildcardQueryBuilder> {
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
throw new QueryParsingException(parseContext, "No value specified for prefix query");
|
||||
throw new ParsingException(parseContext, "No value specified for prefix query");
|
||||
}
|
||||
return new WildcardQueryBuilder(fieldName, value)
|
||||
.rewrite(rewrite)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
@ -35,16 +36,16 @@ public class WrapperQueryParser extends BaseQueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
if (token != XContentParser.Token.FIELD_NAME) {
|
||||
throw new QueryParsingException(parseContext, "[wrapper] query malformed");
|
||||
throw new ParsingException(parseContext, "[wrapper] query malformed");
|
||||
}
|
||||
String fieldName = parser.currentName();
|
||||
if (!fieldName.equals("query")) {
|
||||
throw new QueryParsingException(parseContext, "[wrapper] query malformed");
|
||||
throw new ParsingException(parseContext, "[wrapper] query malformed");
|
||||
}
|
||||
parser.nextToken();
|
||||
|
||||
@ -53,7 +54,7 @@ public class WrapperQueryParser extends BaseQueryParser {
|
||||
parser.nextToken();
|
||||
|
||||
if (source == null) {
|
||||
throw new QueryParsingException(parseContext, "wrapper query has no [query] specified");
|
||||
throw new ParsingException(parseContext, "wrapper query has no [query] specified");
|
||||
}
|
||||
return new WrapperQueryBuilder(source);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ import org.elasticsearch.index.mapper.core.DateFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
||||
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionBuilder;
|
||||
import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionParser;
|
||||
import org.elasticsearch.search.MultiValueMode;
|
||||
@ -118,7 +118,7 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
|
||||
*
|
||||
* */
|
||||
@Override
|
||||
public ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, QueryParsingException {
|
||||
public ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, ParsingException {
|
||||
String currentFieldName;
|
||||
XContentParser.Token token;
|
||||
AbstractDistanceScoreFunction scoreFunction;
|
||||
@ -152,7 +152,7 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
|
||||
// the doc later
|
||||
MappedFieldType fieldType = context.fieldMapper(fieldName);
|
||||
if (fieldType == null) {
|
||||
throw new QueryParsingException(context.parseContext(), "unknown field [{}]", fieldName);
|
||||
throw new ParsingException(context.parseContext(), "unknown field [{}]", fieldName);
|
||||
}
|
||||
|
||||
// dates and time need special handling
|
||||
@ -164,7 +164,7 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
|
||||
} else if (fieldType instanceof NumberFieldMapper.NumberFieldType) {
|
||||
return parseNumberVariable(fieldName, parser, context, (NumberFieldMapper.NumberFieldType) fieldType, mode);
|
||||
} else {
|
||||
throw new QueryParsingException(context.parseContext(), "field [{}] is of type [{}], but only numeric types are supported.", fieldName, fieldType);
|
||||
throw new ParsingException(context.parseContext(), "field [{}] is of type [{}], but only numeric types are supported.", fieldName, fieldType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
@ -74,7 +75,7 @@ public class FunctionScoreQueryParser implements QueryParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(QueryShardContext context) throws IOException, QueryParsingException {
|
||||
public Query parse(QueryShardContext context) throws IOException {
|
||||
QueryParseContext parseContext = context.parseContext();
|
||||
XContentParser parser = parseContext.parser();
|
||||
|
||||
@ -202,7 +203,7 @@ public class FunctionScoreQueryParser implements QueryParser {
|
||||
ScoreFunction scoreFunction = null;
|
||||
Float functionWeight = null;
|
||||
if (token != XContentParser.Token.START_OBJECT) {
|
||||
throw new QueryParsingException(parseContext, "failed to parse [{}]. malformed query, expected a [{}] while parsing functions but got a [{}] instead", XContentParser.Token.START_OBJECT, token, NAME);
|
||||
throw new ParsingException(parseContext, "failed to parse [{}]. malformed query, expected a [{}] while parsing functions but got a [{}] instead", XContentParser.Token.START_OBJECT, token, NAME);
|
||||
} else {
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
@ -252,7 +253,7 @@ public class FunctionScoreQueryParser implements QueryParser {
|
||||
} else if ("first".equals(scoreMode)) {
|
||||
return FiltersFunctionScoreQuery.ScoreMode.First;
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "failed to parse [{}] query. illegal score_mode [{}]", NAME, scoreMode);
|
||||
throw new ParsingException(parseContext, "failed to parse [{}] query. illegal score_mode [{}]", NAME, scoreMode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,14 +261,14 @@ public class FunctionScoreQueryParser implements QueryParser {
|
||||
String boostMode = parser.text();
|
||||
CombineFunction cf = combineFunctionsMap.get(boostMode);
|
||||
if (cf == null) {
|
||||
throw new QueryParsingException(parseContext, "failed to parse [{}] query. illegal boost_mode [{}]", NAME, boostMode);
|
||||
throw new ParsingException(parseContext, "failed to parse [{}] query. illegal boost_mode [{}]", NAME, boostMode);
|
||||
}
|
||||
return cf;
|
||||
}
|
||||
|
||||
//norelease to be removed once all queries are moved over to extend BaseQueryParser
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
Query query = parse(parseContext.shardContext());
|
||||
return new QueryWrappingQueryBuilder(query);
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ package org.elasticsearch.index.query.functionscore;
|
||||
import org.elasticsearch.common.lucene.search.function.ScoreFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface ScoreFunctionParser {
|
||||
|
||||
ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, QueryParsingException;
|
||||
ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, ParsingException;
|
||||
|
||||
/**
|
||||
* Returns the name of the function, for example "linear", "gauss" etc. This
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.index.query.functionscore;
|
||||
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.query.functionscore.exp.ExponentialDecayFunctionParser;
|
||||
import org.elasticsearch.index.query.functionscore.fieldvaluefactor.FieldValueFactorFunctionParser;
|
||||
import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionParser;
|
||||
@ -57,7 +57,7 @@ public class ScoreFunctionParserMapper {
|
||||
public ScoreFunctionParser get(QueryParseContext parseContext, String parserName) {
|
||||
ScoreFunctionParser functionParser = get(parserName);
|
||||
if (functionParser == null) {
|
||||
throw new QueryParsingException(parseContext, "No function with the name [" + parserName + "] is registered.");
|
||||
throw new ParsingException(parseContext, "No function with the name [" + parserName + "] is registered.");
|
||||
}
|
||||
return functionParser;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.index.fielddata.IndexNumericFieldData;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionParser;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
||||
@ -52,7 +52,7 @@ public class FieldValueFactorFunctionParser implements ScoreFunctionParser {
|
||||
public static String[] NAMES = { "field_value_factor", "fieldValueFactor" };
|
||||
|
||||
@Override
|
||||
public ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, QueryParsingException {
|
||||
public ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, ParsingException {
|
||||
QueryParseContext parseContext = context.parseContext();
|
||||
|
||||
String currentFieldName = null;
|
||||
@ -74,15 +74,15 @@ public class FieldValueFactorFunctionParser implements ScoreFunctionParser {
|
||||
} else if ("missing".equals(currentFieldName)) {
|
||||
missing = parser.doubleValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if("factor".equals(currentFieldName) && (token == XContentParser.Token.START_ARRAY || token == XContentParser.Token.START_OBJECT)) {
|
||||
throw new QueryParsingException(parseContext, "[" + NAMES[0] + "] field 'factor' does not support lists or objects");
|
||||
throw new ParsingException(parseContext, "[" + NAMES[0] + "] field 'factor' does not support lists or objects");
|
||||
}
|
||||
}
|
||||
|
||||
if (field == null) {
|
||||
throw new QueryParsingException(parseContext, "[" + NAMES[0] + "] required field 'field' missing");
|
||||
throw new ParsingException(parseContext, "[" + NAMES[0] + "] required field 'field' missing");
|
||||
}
|
||||
|
||||
SearchContext searchContext = SearchContext.current();
|
||||
|
@ -29,7 +29,7 @@ import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionParser;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
@ -50,7 +50,7 @@ public class RandomScoreFunctionParser implements ScoreFunctionParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, QueryParsingException {
|
||||
public ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, ParsingException {
|
||||
QueryParseContext parseContext = context.parseContext();
|
||||
int seed = -1;
|
||||
|
||||
@ -67,17 +67,17 @@ public class RandomScoreFunctionParser implements ScoreFunctionParser {
|
||||
} else if (parser.numberType() == XContentParser.NumberType.LONG) {
|
||||
seed = hash(parser.longValue());
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "random_score seed must be an int, long or string, not '"
|
||||
throw new ParsingException(parseContext, "random_score seed must be an int, long or string, not '"
|
||||
+ token.toString() + "'");
|
||||
}
|
||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||
seed = parser.text().hashCode();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, "random_score seed must be an int/long or string, not '"
|
||||
throw new ParsingException(parseContext, "random_score seed must be an int/long or string, not '"
|
||||
+ token.toString() + "'");
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.lucene.search.function.ScriptScoreFunction;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionParser;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.Script.ScriptField;
|
||||
@ -57,7 +57,7 @@ public class ScriptScoreFunctionParser implements ScoreFunctionParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, QueryParsingException {
|
||||
public ScoreFunction parse(QueryShardContext context, XContentParser parser) throws IOException, ParsingException {
|
||||
QueryParseContext parseContext = context.parseContext();
|
||||
ScriptParameterParser scriptParameterParser = new ScriptParameterParser();
|
||||
Script script = null;
|
||||
@ -73,11 +73,11 @@ public class ScriptScoreFunctionParser implements ScoreFunctionParser {
|
||||
} else if ("params".equals(currentFieldName)) { // TODO remove in 3.0 (here to support old script APIs)
|
||||
vars = parser.map();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if (!scriptParameterParser.token(currentFieldName, token, parser, parseContext.parseFieldMatcher())) {
|
||||
throw new QueryParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
|
||||
throw new ParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,11 +91,11 @@ public class ScriptScoreFunctionParser implements ScoreFunctionParser {
|
||||
script = new Script(scriptValue.script(), scriptValue.scriptType(), scriptParameterParser.lang(), vars);
|
||||
}
|
||||
} else if (vars != null) {
|
||||
throw new QueryParsingException(parseContext, "script params must be specified inside script object");
|
||||
throw new ParsingException(parseContext, "script params must be specified inside script object");
|
||||
}
|
||||
|
||||
if (script == null) {
|
||||
throw new QueryParsingException(parseContext, NAMES[0] + " requires 'script' field");
|
||||
throw new ParsingException(parseContext, NAMES[0] + " requires 'script' field");
|
||||
}
|
||||
|
||||
SearchScript searchScript;
|
||||
@ -103,7 +103,7 @@ public class ScriptScoreFunctionParser implements ScoreFunctionParser {
|
||||
searchScript = context.scriptService().search(context.lookup(), script, ScriptContext.Standard.SEARCH);
|
||||
return new ScriptScoreFunction(script, searchScript);
|
||||
} catch (Exception e) {
|
||||
throw new QueryParsingException(parseContext, NAMES[0] + " the script could not be loaded", e);
|
||||
throw new ParsingException(parseContext, NAMES[0] + " the script could not be loaded", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.query.QueryShardException;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.search.fetch.fielddata.FieldDataFieldsParseElement;
|
||||
import org.elasticsearch.search.fetch.innerhits.InnerHitsSubSearchContext;
|
||||
import org.elasticsearch.search.fetch.script.ScriptFieldsParseElement;
|
||||
|
@ -38,7 +38,7 @@ import org.elasticsearch.index.engine.IgnoreOnRecoveryEngineException;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
import org.elasticsearch.index.query.ParsedQuery;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.translog.Translog;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -214,7 +214,7 @@ public class TranslogRecoveryPerformer {
|
||||
Query query;
|
||||
try {
|
||||
query = queryParserService.parseQuery(source).query();
|
||||
} catch (QueryParsingException ex) {
|
||||
} catch (ParsingException ex) {
|
||||
// for BWC we try to parse directly the query since pre 1.0.0.Beta2 we didn't require a top level query field
|
||||
if (queryParserService.getIndexCreatedVersion().onOrBefore(Version.V_1_0_0_Beta2)) {
|
||||
try {
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.search.aggregations.bucket.significant.heuristics;
|
||||
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -30,7 +30,7 @@ import java.io.IOException;
|
||||
public interface SignificanceHeuristicParser {
|
||||
|
||||
SignificanceHeuristic parse(XContentParser parser, ParseFieldMatcher parseFieldMatcher, SearchContext context) throws IOException,
|
||||
QueryParsingException;
|
||||
ParsingException;
|
||||
|
||||
String[] getNames();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import org.apache.lucene.store.LockObtainFailedException;
|
||||
import org.apache.lucene.util.Constants;
|
||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
@ -86,9 +87,9 @@ public class ESExceptionTests extends ESTestCase {
|
||||
assertEquals(rootCauses.length, 1);
|
||||
assertEquals(ElasticsearchException.getExceptionName(rootCauses[0]), "index_not_found_exception");
|
||||
assertEquals(rootCauses[0].getMessage(), "no such index");
|
||||
ShardSearchFailure failure = new ShardSearchFailure(new TestQueryParsingException(new Index("foo"), "foobar", null),
|
||||
ShardSearchFailure failure = new ShardSearchFailure(new TestParsingException(new Index("foo"), "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo", 1));
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestQueryParsingException(new Index("foo"), "foobar", null),
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestParsingException(new Index("foo"), "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo", 2));
|
||||
SearchPhaseExecutionException ex = new SearchPhaseExecutionException("search", "all shards failed", new ShardSearchFailure[]{failure, failure1});
|
||||
if (randomBoolean()) {
|
||||
@ -106,22 +107,22 @@ public class ESExceptionTests extends ESTestCase {
|
||||
}
|
||||
{
|
||||
ShardSearchFailure failure = new ShardSearchFailure(
|
||||
new TestQueryParsingException(new Index("foo"), 1, 2, "foobar", null),
|
||||
new TestParsingException(new Index("foo"), 1, 2, "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo", 1));
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestQueryParsingException(new Index("foo1"), 1, 2, "foobar", null),
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestParsingException(new Index("foo1"), 1, 2, "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo1", 1));
|
||||
ShardSearchFailure failure2 = new ShardSearchFailure(new TestQueryParsingException(new Index("foo1"), 1, 2, "foobar", null),
|
||||
ShardSearchFailure failure2 = new ShardSearchFailure(new TestParsingException(new Index("foo1"), 1, 2, "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo1", 2));
|
||||
SearchPhaseExecutionException ex = new SearchPhaseExecutionException("search", "all shards failed", new ShardSearchFailure[]{failure, failure1, failure2});
|
||||
final ElasticsearchException[] rootCauses = ex.guessRootCauses();
|
||||
assertEquals(rootCauses.length, 2);
|
||||
assertEquals(ElasticsearchException.getExceptionName(rootCauses[0]), "test_query_parsing_exception");
|
||||
assertEquals(rootCauses[0].getMessage(), "foobar");
|
||||
assertEquals(((QueryParsingException)rootCauses[0]).getIndex(), "foo");
|
||||
assertEquals(((ParsingException)rootCauses[0]).getIndex(), "foo");
|
||||
assertEquals(ElasticsearchException.getExceptionName(rootCauses[1]), "test_query_parsing_exception");
|
||||
assertEquals(rootCauses[1].getMessage(), "foobar");
|
||||
assertEquals(((QueryParsingException) rootCauses[1]).getLineNumber(), 1);
|
||||
assertEquals(((QueryParsingException) rootCauses[1]).getColumnNumber(), 2);
|
||||
assertEquals(((ParsingException) rootCauses[1]).getLineNumber(), 1);
|
||||
assertEquals(((ParsingException) rootCauses[1]).getColumnNumber(), 2);
|
||||
|
||||
}
|
||||
|
||||
@ -138,9 +139,9 @@ public class ESExceptionTests extends ESTestCase {
|
||||
|
||||
public void testDeduplicate() throws IOException {
|
||||
{
|
||||
ShardSearchFailure failure = new ShardSearchFailure(new TestQueryParsingException(new Index("foo"), "foobar", null),
|
||||
ShardSearchFailure failure = new ShardSearchFailure(new TestParsingException(new Index("foo"), "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo", 1));
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestQueryParsingException(new Index("foo"), "foobar", null),
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestParsingException(new Index("foo"), "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo", 2));
|
||||
SearchPhaseExecutionException ex = new SearchPhaseExecutionException("search", "all shards failed", new ShardSearchFailure[]{failure, failure1});
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
@ -151,11 +152,11 @@ public class ESExceptionTests extends ESTestCase {
|
||||
assertEquals(expected, builder.string());
|
||||
}
|
||||
{
|
||||
ShardSearchFailure failure = new ShardSearchFailure(new TestQueryParsingException(new Index("foo"), "foobar", null),
|
||||
ShardSearchFailure failure = new ShardSearchFailure(new TestParsingException(new Index("foo"), "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo", 1));
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestQueryParsingException(new Index("foo1"), "foobar", null),
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestParsingException(new Index("foo1"), "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo1", 1));
|
||||
ShardSearchFailure failure2 = new ShardSearchFailure(new TestQueryParsingException(new Index("foo1"), "foobar", null),
|
||||
ShardSearchFailure failure2 = new ShardSearchFailure(new TestParsingException(new Index("foo1"), "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo1", 2));
|
||||
SearchPhaseExecutionException ex = new SearchPhaseExecutionException("search", "all shards failed", new ShardSearchFailure[]{failure, failure1, failure2});
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
@ -218,7 +219,7 @@ public class ESExceptionTests extends ESTestCase {
|
||||
}
|
||||
|
||||
{
|
||||
QueryParsingException ex = new TestQueryParsingException(new Index("foo"), 1, 2, "foobar", null);
|
||||
ParsingException ex = new TestParsingException(new Index("foo"), 1, 2, "foobar", null);
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
ElasticsearchException.toXContent(builder, PARAMS, ex);
|
||||
@ -244,7 +245,7 @@ public class ESExceptionTests extends ESTestCase {
|
||||
}
|
||||
|
||||
{ // render header
|
||||
QueryParsingException ex = new TestQueryParsingException(new Index("foo"), 1, 2, "foobar", null);
|
||||
ParsingException ex = new TestParsingException(new Index("foo"), 1, 2, "foobar", null);
|
||||
ex.addHeader("test", "some value");
|
||||
ex.addHeader("test_multi", "some value", "another value");
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
@ -260,11 +261,11 @@ public class ESExceptionTests extends ESTestCase {
|
||||
|
||||
public void testSerializeElasticsearchException() throws IOException {
|
||||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
QueryParsingException ex = new QueryParsingException(new Index("foo"), 1, 2, "foobar", null);
|
||||
ParsingException ex = new ParsingException(new Index("foo"), 1, 2, "foobar", null);
|
||||
out.writeThrowable(ex);
|
||||
|
||||
StreamInput in = StreamInput.wrap(out.bytes());
|
||||
QueryParsingException e = in.readThrowable();
|
||||
ParsingException e = in.readThrowable();
|
||||
assertEquals(ex.getIndex(), e.getIndex());
|
||||
assertEquals(ex.getMessage(), e.getMessage());
|
||||
assertEquals(ex.getLineNumber(), e.getLineNumber());
|
||||
@ -273,19 +274,19 @@ public class ESExceptionTests extends ESTestCase {
|
||||
|
||||
public void testSerializeUnknownException() throws IOException {
|
||||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
QueryParsingException queryParsingException = new QueryParsingException(new Index("foo"), 1, 2, "foobar", null);
|
||||
Throwable ex = new Throwable("wtf", queryParsingException);
|
||||
ParsingException ParsingException = new ParsingException(new Index("foo"), 1, 2, "foobar", null);
|
||||
Throwable ex = new Throwable("wtf", ParsingException);
|
||||
out.writeThrowable(ex);
|
||||
|
||||
StreamInput in = StreamInput.wrap(out.bytes());
|
||||
Throwable throwable = in.readThrowable();
|
||||
assertEquals("wtf", throwable.getMessage());
|
||||
assertTrue(throwable instanceof ElasticsearchException);
|
||||
QueryParsingException e = (QueryParsingException)throwable.getCause();
|
||||
assertEquals(queryParsingException.getIndex(), e.getIndex());
|
||||
assertEquals(queryParsingException.getMessage(), e.getMessage());
|
||||
assertEquals(queryParsingException.getLineNumber(), e.getLineNumber());
|
||||
assertEquals(queryParsingException.getColumnNumber(), e.getColumnNumber());
|
||||
ParsingException e = (ParsingException)throwable.getCause();
|
||||
assertEquals(ParsingException.getIndex(), e.getIndex());
|
||||
assertEquals(ParsingException.getMessage(), e.getMessage());
|
||||
assertEquals(ParsingException.getLineNumber(), e.getLineNumber());
|
||||
assertEquals(ParsingException.getColumnNumber(), e.getColumnNumber());
|
||||
}
|
||||
|
||||
public void testWriteThrowable() throws IOException {
|
||||
|
@ -60,7 +60,7 @@ import org.elasticsearch.index.engine.CreateFailedEngineException;
|
||||
import org.elasticsearch.index.engine.IndexFailedEngineException;
|
||||
import org.elasticsearch.index.engine.RecoveryEngineException;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.query.QueryShardException;
|
||||
import org.elasticsearch.index.shard.IllegalIndexShardStateException;
|
||||
import org.elasticsearch.index.shard.IndexShardState;
|
||||
@ -111,7 +111,7 @@ public class ExceptionSerializationTests extends ESTestCase {
|
||||
final Path startPath = PathUtils.get(ElasticsearchException.class.getProtectionDomain().getCodeSource().getLocation().toURI()).resolve("org").resolve("elasticsearch");
|
||||
final Set<? extends Class> ignore = Sets.newHashSet(
|
||||
org.elasticsearch.test.rest.parser.RestTestParseException.class,
|
||||
org.elasticsearch.index.query.TestQueryParsingException.class,
|
||||
org.elasticsearch.index.query.TestParsingException.class,
|
||||
org.elasticsearch.test.rest.client.RestException.class,
|
||||
CancellableThreadsTests.CustomException.class,
|
||||
org.elasticsearch.rest.BytesRestResponseTests.WithHeadersException.class,
|
||||
@ -226,14 +226,14 @@ public class ExceptionSerializationTests extends ESTestCase {
|
||||
assertNull(serialize.getCause());
|
||||
}
|
||||
|
||||
public void testQueryParsingException() throws IOException {
|
||||
QueryParsingException ex = serialize(new QueryParsingException(new Index("foo"), 1, 2, "fobar", null));
|
||||
public void testParsingException() throws IOException {
|
||||
ParsingException ex = serialize(new ParsingException(new Index("foo"), 1, 2, "fobar", null));
|
||||
assertEquals(ex.getIndex(), "foo");
|
||||
assertEquals(ex.getMessage(), "fobar");
|
||||
assertEquals(ex.getLineNumber(),1);
|
||||
assertEquals(ex.getColumnNumber(), 2);
|
||||
|
||||
ex = serialize(new QueryParsingException(null, 1, 2, null, null));
|
||||
ex = serialize(new ParsingException(null, 1, 2, null, null));
|
||||
assertNull(ex.getIndex());
|
||||
assertNull(ex.getMessage());
|
||||
assertEquals(ex.getLineNumber(),1);
|
||||
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -50,9 +51,9 @@ public class ConstantScoreQueryBuilderTests extends AbstractQueryTestCase<Consta
|
||||
}
|
||||
|
||||
/**
|
||||
* test that missing "filter" element causes {@link QueryParsingException}
|
||||
* test that missing "filter" element causes {@link ParsingException}
|
||||
*/
|
||||
@Test(expected=QueryParsingException.class)
|
||||
@Test(expected=ParsingException.class)
|
||||
public void testFilterElement() throws IOException {
|
||||
String queryString = "{ \"" + ConstantScoreQueryBuilder.NAME + "\" : {}";
|
||||
parseQuery(queryString);
|
||||
|
@ -84,10 +84,9 @@ public class DisMaxQueryBuilderTests extends AbstractQueryTestCase<DisMaxQueryBu
|
||||
/**
|
||||
* test `null`return value for missing inner queries
|
||||
* @throws IOException
|
||||
* @throws QueryParsingException
|
||||
*/
|
||||
@Test
|
||||
public void testNoInnerQueries() throws QueryParsingException, IOException {
|
||||
public void testNoInnerQueries() throws IOException {
|
||||
DisMaxQueryBuilder disMaxBuilder = new DisMaxQueryBuilder();
|
||||
assertNull(disMaxBuilder.toQuery(createShardContext()));
|
||||
assertNull(disMaxBuilder.validate());
|
||||
|
@ -24,6 +24,7 @@ import org.apache.lucene.queries.TermsQuery;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -39,7 +40,7 @@ public class IdsQueryBuilderTests extends AbstractQueryTestCase<IdsQueryBuilder>
|
||||
* check that parser throws exception on missing values field
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test(expected=QueryParsingException.class)
|
||||
@Test(expected=ParsingException.class)
|
||||
public void testIdsNotProvided() throws IOException {
|
||||
String noIdsFieldQuery = "{\"ids\" : { \"type\" : \"my_type\" }";
|
||||
parseQuery(noIdsFieldQuery);
|
||||
|
@ -83,7 +83,7 @@ public class IndexQueryParserFilterDateRangeFormatTests extends ESSingleNodeTest
|
||||
SearchContext.setCurrent(new TestSearchContext());
|
||||
// We need to rewrite, because range on date field initially returns LateParsingQuery
|
||||
queryParser.parse(query).query().rewrite(null);
|
||||
fail("A Range Filter with a specific format but with an unexpected date should raise a QueryParsingException");
|
||||
fail("A Range Filter with a specific format but with an unexpected date should raise a ParsingException");
|
||||
} catch (ElasticsearchParseException e) {
|
||||
// We expect it
|
||||
} finally {
|
||||
@ -119,7 +119,7 @@ public class IndexQueryParserFilterDateRangeFormatTests extends ESSingleNodeTest
|
||||
try {
|
||||
SearchContext.setCurrent(new TestSearchContext());
|
||||
queryParser.parse(query).query().rewrite(null);
|
||||
fail("A Range Query with a specific format but with an unexpected date should raise a QueryParsingException");
|
||||
fail("A Range Query with a specific format but with an unexpected date should raise a ParsingException");
|
||||
} catch (ElasticsearchParseException e) {
|
||||
// We expect it
|
||||
} finally {
|
||||
|
@ -82,7 +82,7 @@ public class IndexQueryParserFilterDateRangeTimezoneTests extends ESSingleNodeTe
|
||||
try {
|
||||
SearchContext.setCurrent(new TestSearchContext());
|
||||
queryParser.parse(query).query();
|
||||
fail("A Range Filter on a numeric field with a TimeZone should raise a QueryParsingException");
|
||||
fail("A Range Filter on a numeric field with a TimeZone should raise a ParsingException");
|
||||
} catch (QueryShardException e) {
|
||||
// We expect it
|
||||
} finally {
|
||||
@ -119,7 +119,7 @@ public class IndexQueryParserFilterDateRangeTimezoneTests extends ESSingleNodeTe
|
||||
try {
|
||||
SearchContext.setCurrent(new TestSearchContext());
|
||||
queryParser.parse(query).query();
|
||||
fail("A Range Query on a numeric field with a TimeZone should raise a QueryParsingException");
|
||||
fail("A Range Query on a numeric field with a TimeZone should raise a ParsingException");
|
||||
} catch (QueryShardException e) {
|
||||
// We expect it
|
||||
} finally {
|
||||
|
@ -24,6 +24,7 @@ import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -61,7 +62,7 @@ public class NotQueryBuilderTests extends AbstractQueryTestCase<NotQueryBuilder>
|
||||
/**
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test(expected=QueryParsingException.class)
|
||||
@Test(expected=ParsingException.class)
|
||||
public void testMissingFilterSection() throws IOException {
|
||||
String queryString = "{ \"not\" : {}";
|
||||
parseQuery(queryString);
|
||||
|
@ -64,6 +64,7 @@ import org.apache.lucene.util.automaton.TooComplexToDeterminizeException;
|
||||
import org.elasticsearch.action.support.PlainActionFuture;
|
||||
import org.elasticsearch.action.termvectors.*;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
import org.elasticsearch.common.lucene.search.MoreLikeThisQuery;
|
||||
@ -315,8 +316,8 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
|
||||
try {
|
||||
queryParser.parse(copyToStringFromClasspath("/org/elasticsearch/index/query/query-timezone-incorrect.json"));
|
||||
fail("we expect a QueryParsingException as we are providing an unknown time_zome");
|
||||
} catch (QueryParsingException e) {
|
||||
fail("we expect a ParsingException as we are providing an unknown time_zome");
|
||||
} catch (ParsingException e) {
|
||||
// We expect this one
|
||||
}
|
||||
}
|
||||
@ -338,7 +339,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
fail("did not hit exception");
|
||||
} catch (QueryParsingException qpe) {
|
||||
} catch (ParsingException qpe) {
|
||||
// expected
|
||||
assertTrue(qpe.getCause() instanceof TooComplexToDeterminizeException);
|
||||
}
|
||||
@ -464,7 +465,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
assertThat(fieldQuery.getTerm().bytes(), equalTo(indexedValueForSearch(34l)));
|
||||
}
|
||||
|
||||
@Test(expected = QueryParsingException.class)
|
||||
@Test(expected = ParsingException.class)
|
||||
public void testTermQueryArrayInvalid() throws IOException {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/term-array-invalid.json");
|
||||
@ -917,7 +918,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
fail();
|
||||
} catch (QueryParsingException ex) {
|
||||
} catch (ParsingException ex) {
|
||||
assertThat(ex.getMessage(), equalTo("[terms] query does not support multiple fields"));
|
||||
}
|
||||
}
|
||||
@ -931,7 +932,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
fail();
|
||||
} catch (QueryParsingException ex) {
|
||||
} catch (ParsingException ex) {
|
||||
assertThat(ex.getMessage(), equalTo("[terms] query does not support multiple fields"));
|
||||
}
|
||||
}
|
||||
@ -963,7 +964,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
try {
|
||||
queryParser.parse(query);
|
||||
fail("Expected Query Parsing Exception but did not happen");
|
||||
} catch (QueryParsingException e) {
|
||||
} catch (ParsingException e) {
|
||||
assertThat(e.getMessage(), containsString("[term] query does not support different field names, use [bool] query instead"));
|
||||
}
|
||||
}
|
||||
@ -1757,7 +1758,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
fail("parsing a broken geo_polygon filter didn't fail as expected while parsing: " + brokenFile);
|
||||
} catch (QueryParsingException e) {
|
||||
} catch (ParsingException e) {
|
||||
// success!
|
||||
}
|
||||
}
|
||||
@ -1893,7 +1894,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
assertTrue(ectQuery.isCoordDisabled());
|
||||
}
|
||||
|
||||
@Test(expected = QueryParsingException.class)
|
||||
@Test(expected = ParsingException.class)
|
||||
public void assureMalformedThrowsException() throws IOException {
|
||||
IndexQueryParserService queryParser;
|
||||
queryParser = queryParser();
|
||||
@ -1916,10 +1917,10 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
public void testBadTypeMatchQuery() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/match-query-bad-type.json");
|
||||
QueryParsingException expectedException = null;
|
||||
ParsingException expectedException = null;
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
} catch (QueryParsingException qpe) {
|
||||
} catch (ParsingException qpe) {
|
||||
expectedException = qpe;
|
||||
}
|
||||
assertThat(expectedException, notNullValue());
|
||||
@ -1937,10 +1938,10 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
public void testBadTypeMultiMatchQuery() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/multiMatch-query-bad-type.json");
|
||||
QueryParsingException expectedException = null;
|
||||
ParsingException expectedException = null;
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
} catch (QueryParsingException qpe) {
|
||||
} catch (ParsingException qpe) {
|
||||
expectedException = qpe;
|
||||
}
|
||||
assertThat(expectedException, notNullValue());
|
||||
@ -2003,7 +2004,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
fail("FunctionScoreQueryParser should throw an exception here because two functions in body are not allowed.");
|
||||
} catch (QueryParsingException e) {
|
||||
} catch (ParsingException e) {
|
||||
assertThat(e.getDetailedMessage(), containsString("use [functions] array if you want to define several functions."));
|
||||
}
|
||||
}
|
||||
@ -2048,7 +2049,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
fail("Expect exception here because array of functions and one weight in body is not allowed.");
|
||||
} catch (QueryParsingException e) {
|
||||
} catch (ParsingException e) {
|
||||
assertThat(e.getDetailedMessage(), containsString("you can either define [functions] array or a single function, not both. already found [functions] array, now encountering [weight]."));
|
||||
}
|
||||
query = jsonBuilder().startObject().startObject("function_score")
|
||||
@ -2060,7 +2061,7 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
try {
|
||||
queryParser.parse(query).query();
|
||||
fail("Expect exception here because array of functions and one weight in body is not allowed.");
|
||||
} catch (QueryParsingException e) {
|
||||
} catch (ParsingException e) {
|
||||
assertThat(e.getDetailedMessage(), containsString("you can either define [functions] array or a single function, not both. already found [weight], now encountering [functions]."));
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.spans.SpanFirstQuery;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.junit.Test;
|
||||
@ -61,7 +62,7 @@ public class SpanFirstQueryBuilderTests extends AbstractQueryTestCase<SpanFirstQ
|
||||
try {
|
||||
parseQuery(builder.string());
|
||||
fail("missing [end] parameter should raise exception");
|
||||
} catch (QueryParsingException e) {
|
||||
} catch (ParsingException e) {
|
||||
assertTrue(e.getMessage().contains("spanFirst must have [end] set"));
|
||||
}
|
||||
}
|
||||
@ -77,7 +78,7 @@ public class SpanFirstQueryBuilderTests extends AbstractQueryTestCase<SpanFirstQ
|
||||
try {
|
||||
parseQuery(builder.string());
|
||||
fail("missing [match] parameter should raise exception");
|
||||
} catch (QueryParsingException e) {
|
||||
} catch (ParsingException e) {
|
||||
assertTrue(e.getMessage().contains("spanFirst must have [match] span query clause"));
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.query;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.spans.SpanNotQuery;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.junit.Test;
|
||||
@ -142,9 +143,9 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
|
||||
|
||||
try {
|
||||
parseQuery(builder.string());
|
||||
fail("QueryParsingException should have been caught");
|
||||
} catch (QueryParsingException e) {
|
||||
assertThat("QueryParsingException should have been caught", e.getDetailedMessage(), containsString("spanNot must have [include]"));
|
||||
fail("ParsingException should have been caught");
|
||||
} catch (ParsingException e) {
|
||||
assertThat("ParsingException should have been caught", e.getDetailedMessage(), containsString("spanNot must have [include]"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,9 +162,9 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
|
||||
|
||||
try {
|
||||
parseQuery(builder.string());
|
||||
fail("QueryParsingException should have been caught");
|
||||
} catch (QueryParsingException e) {
|
||||
assertThat("QueryParsingException should have been caught", e.getDetailedMessage(), containsString("spanNot must have [exclude]"));
|
||||
fail("ParsingException should have been caught");
|
||||
} catch (ParsingException e) {
|
||||
assertThat("ParsingException should have been caught", e.getDetailedMessage(), containsString("spanNot must have [exclude]"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,9 +184,9 @@ public class SpanNotQueryBuilderTests extends AbstractQueryTestCase<SpanNotQuery
|
||||
|
||||
try {
|
||||
parseQuery(builder.string());
|
||||
fail("QueryParsingException should have been caught");
|
||||
} catch (QueryParsingException e) {
|
||||
assertThat("QueryParsingException should have been caught", e.getDetailedMessage(), containsString("spanNot can either use [dist] or [pre] & [post] (or none)"));
|
||||
fail("ParsingException should have been caught");
|
||||
} catch (ParsingException e) {
|
||||
assertThat("ParsingException should have been caught", e.getDetailedMessage(), containsString("spanNot can either use [dist] or [pre] & [post] (or none)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.elasticsearch.Version;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
import org.elasticsearch.common.inject.ModulesBuilder;
|
||||
@ -151,7 +152,7 @@ public class TemplateQueryParserTests extends ESTestCase {
|
||||
* expressed as a single string but still it expects only the query
|
||||
* specification (thus this test should fail with specific exception).
|
||||
*/
|
||||
@Test(expected = QueryParsingException.class)
|
||||
@Test(expected = ParsingException.class)
|
||||
public void testParseTemplateFailsToParseCompleteQueryAsSingleString() throws IOException {
|
||||
String templateString = "{" + " \"inline\" : \"{ \\\"size\\\": \\\"{{size}}\\\", \\\"query\\\":{\\\"match_all\\\":{}}}\","
|
||||
+ " \"params\":{" + " \"size\":2" + " }\n" + "}";
|
||||
|
@ -19,19 +19,20 @@
|
||||
|
||||
package org.elasticsearch.index.query;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.Index;
|
||||
|
||||
/**
|
||||
* Class used to avoid dragging QueryContext into unit testing framework for
|
||||
* basic exception handling
|
||||
*/
|
||||
public class TestQueryParsingException extends QueryParsingException {
|
||||
public class TestParsingException extends ParsingException {
|
||||
|
||||
public TestQueryParsingException(Index index, int line, int col, String msg, Throwable cause) {
|
||||
public TestParsingException(Index index, int line, int col, String msg, Throwable cause) {
|
||||
super(index, line, col, msg, cause);
|
||||
}
|
||||
|
||||
public TestQueryParsingException(Index index, String msg, Throwable cause) {
|
||||
public TestParsingException(Index index, String msg, Throwable cause) {
|
||||
super(index, UNKNOWN_POSITION, UNKNOWN_POSITION, msg, cause);
|
||||
}
|
||||
}
|
@ -73,7 +73,7 @@ public class DummyQueryParserPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
XContentParser.Token token = parseContext.parser().nextToken();
|
||||
assert token == XContentParser.Token.END_OBJECT;
|
||||
return new DummyQueryBuilder();
|
||||
|
@ -59,7 +59,7 @@ import org.elasticsearch.index.mapper.Mapping;
|
||||
import org.elasticsearch.index.mapper.ParseContext;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.settings.IndexSettingsService;
|
||||
import org.elasticsearch.index.store.Store;
|
||||
import org.elasticsearch.index.translog.Translog;
|
||||
@ -75,7 +75,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@ -405,7 +404,7 @@ public class IndexShardTests extends ESSingleNodeTestCase {
|
||||
shard.engine().config().getTranslogRecoveryPerformer().performRecoveryOperation(shard.engine(), new Translog.DeleteByQuery(new Engine.DeleteByQuery(null, new BytesArray("{\"term\" : { \"user\" : \"kimchy\" }}"), null, null, null, Engine.Operation.Origin.RECOVERY, 0, "person")), false);
|
||||
assertTrue(version.onOrBefore(Version.V_1_0_0_Beta2));
|
||||
numDocs = 0;
|
||||
} catch (QueryParsingException ex) {
|
||||
} catch (ParsingException ex) {
|
||||
assertTrue(version.after(Version.V_1_0_0_Beta2));
|
||||
} finally {
|
||||
shard.state = IndexShardState.STARTED;
|
||||
|
@ -38,12 +38,12 @@ public class IndicesModuleTests extends ModuleTestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||
public QueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(QueryShardContext context) throws IOException, QueryParsingException {
|
||||
public Query parse(QueryShardContext context) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ import org.elasticsearch.cluster.metadata.AliasMetaData;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.indices.IndexTemplateAlreadyExistsException;
|
||||
import org.elasticsearch.indices.InvalidAliasNameException;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
@ -505,7 +505,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
|
||||
fail("index creation should have failed due to invalid alias filter in matching index template");
|
||||
} catch(IllegalArgumentException e) {
|
||||
assertThat(e.getMessage(), equalTo("failed to parse filter for alias [invalid_alias]"));
|
||||
assertThat(e.getCause(), instanceOf(QueryParsingException.class));
|
||||
assertThat(e.getCause(), instanceOf(ParsingException.class));
|
||||
assertThat(e.getCause().getMessage(), equalTo("No query registered for [invalid]"));
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ import org.elasticsearch.index.query.Operator;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.QueryShardException;
|
||||
import org.elasticsearch.index.query.support.QueryInnerHits;
|
||||
import org.elasticsearch.index.query.QueryParsingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.query.functionscore.weight.WeightBuilder;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.script.Script;
|
||||
|
@ -24,7 +24,7 @@ import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.query.TestQueryParsingException;
|
||||
import org.elasticsearch.index.query.TestParsingException;
|
||||
import org.elasticsearch.search.SearchShardTarget;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestRequest;
|
||||
@ -142,17 +142,17 @@ public class BytesRestResponseTests extends ESTestCase {
|
||||
public void testConvert() throws IOException {
|
||||
RestRequest request = new FakeRestRequest();
|
||||
RestChannel channel = new DetailedExceptionRestChannel(request);
|
||||
ShardSearchFailure failure = new ShardSearchFailure(new TestQueryParsingException(new Index("foo"), "foobar", null),
|
||||
ShardSearchFailure failure = new ShardSearchFailure(new TestParsingException(new Index("foo"), "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo", 1));
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestQueryParsingException(new Index("foo"), "foobar", null),
|
||||
ShardSearchFailure failure1 = new ShardSearchFailure(new TestParsingException(new Index("foo"), "foobar", null),
|
||||
new SearchShardTarget("node_1", "foo", 2));
|
||||
SearchPhaseExecutionException ex = new SearchPhaseExecutionException("search", "all shards failed", new ShardSearchFailure[] {failure, failure1});
|
||||
BytesRestResponse response = new BytesRestResponse(channel, new RemoteTransportException("foo", ex));
|
||||
String text = response.content().toUtf8();
|
||||
String expected = "{\"error\":{\"root_cause\":[{\"type\":\"test_query_parsing_exception\",\"reason\":\"foobar\",\"index\":\"foo\"}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"search\",\"grouped\":true,\"failed_shards\":[{\"shard\":1,\"index\":\"foo\",\"node\":\"node_1\",\"reason\":{\"type\":\"test_query_parsing_exception\",\"reason\":\"foobar\",\"index\":\"foo\"}}]},\"status\":400}";
|
||||
String expected = "{\"error\":{\"root_cause\":[{\"type\":\"test_parsing_exception\",\"reason\":\"foobar\",\"index\":\"foo\"}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"search\",\"grouped\":true,\"failed_shards\":[{\"shard\":1,\"index\":\"foo\",\"node\":\"node_1\",\"reason\":{\"type\":\"test_parsing_exception\",\"reason\":\"foobar\",\"index\":\"foo\"}}]},\"status\":400}";
|
||||
assertEquals(expected.trim(), text.trim());
|
||||
String stackTrace = ExceptionsHelper.stackTrace(ex);
|
||||
assertTrue(stackTrace.contains("Caused by: [foo] TestQueryParsingException[foobar]"));
|
||||
assertTrue(stackTrace.contains("Caused by: [foo] TestParsingException[foobar]"));
|
||||
}
|
||||
|
||||
public static class WithHeadersException extends ElasticsearchException {
|
||||
|
@ -2113,7 +2113,7 @@ functionScoreQuery(scriptFunction(new Script("_doc['score'].value")))).setMinSco
|
||||
client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.rangeQuery("date").from(1388534400000L).to(1388537940999L).timeZone("+01:00"))
|
||||
.get();
|
||||
fail("A Range Filter using ms since epoch with a TimeZone should raise a QueryParsingException");
|
||||
fail("A Range Filter using ms since epoch with a TimeZone should raise a ParsingException");
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
// We expect it
|
||||
}
|
||||
@ -2135,7 +2135,7 @@ functionScoreQuery(scriptFunction(new Script("_doc['score'].value")))).setMinSco
|
||||
client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.rangeQuery("num").from("0").to("4").timeZone("-01:00"))
|
||||
.get();
|
||||
fail("A Range Filter on a numeric field with a TimeZone should raise a QueryParsingException");
|
||||
fail("A Range Filter on a numeric field with a TimeZone should raise a ParsingException");
|
||||
} catch (SearchPhaseExecutionException e) {
|
||||
// We expect it
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user