org.elasticsearch.index.query.QueryShardException Java Examples

The following examples show how to use org.elasticsearch.index.query.QueryShardException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrecompiledTemplateFeature.java    From elasticsearch-learning-to-rank with Apache License 2.0 6 votes vote down vote up
@Override
public Query doToQuery(LtrQueryContext context, FeatureSet set, Map<String, Object> params) {
    List<String> missingParams = queryParams.stream()
            .filter((x) -> params == null || !params.containsKey(x))
            .collect(Collectors.toList());
    if (!missingParams.isEmpty()) {
        String names = missingParams.stream().collect(Collectors.joining(","));
        throw new IllegalArgumentException("Missing required param(s): [" + names + "]");
    }

    String query = MustacheUtils.execute(template, params);
    try {
        XContentParser parser = XContentFactory.xContent(query)
                .createParser(context.getQueryShardContext().getXContentRegistry(),
                        LoggingDeprecationHandler.INSTANCE, query);
        QueryBuilder queryBuilder = parseInnerQueryBuilder(parser);
        // XXX: QueryShardContext extends QueryRewriteContext (for now)
        return Rewriteable.rewrite(queryBuilder, context.getQueryShardContext()).toQuery(context.getQueryShardContext());
    } catch (IOException | ParsingException | IllegalArgumentException e) {
        // wrap common exceptions as well so we can attach the feature's name to the stack
        throw new QueryShardException(context.getQueryShardContext(), "Cannot create query while parsing feature [" + name + "]", e);
    }
}
 
Example #2
Source File: MinHashFieldMapper.java    From elasticsearch-minhash with Apache License 2.0 4 votes vote down vote up
@Override
public Query termQuery(final Object value, final QueryShardContext context) {
    throw new QueryShardException(context,
            "MinHash fields do not support searching");
}
 
Example #3
Source File: SourceFieldMapper.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Query existsQuery(QueryShardContext context) {
    throw new QueryShardException(context, "The _source field is not searchable");
}
 
Example #4
Source File: SourceFieldMapper.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Query termQuery(Object value, QueryShardContext context) {
    throw new QueryShardException(context, "The _source field is not searchable");
}
 
Example #5
Source File: VersionFieldMapper.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Query termQuery(Object value, QueryShardContext context) {
    throw new QueryShardException(context, "The _version field is not searchable");
}
 
Example #6
Source File: GeoShapeFieldMapper.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Query termQuery(Object value, QueryShardContext context) {
    throw new QueryShardException(context, "Geo fields do not support exact searching, use dedicated geo queries instead");
}
 
Example #7
Source File: GeoPointFieldMapper.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Query termQuery(Object value, QueryShardContext context) {
    throw new QueryShardException(context, "Geo fields do not support exact searching, use dedicated geo queries instead: ["
                                           + name() + "]");
}
 
Example #8
Source File: MappedFieldType.java    From crate with Apache License 2.0 4 votes vote down vote up
public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) {
    throw new QueryShardException(context, "Can only use prefix queries on keyword and text fields - not on [" + name + "] which is of type [" + typeName() + "]");
}