Java Code Examples for org.elasticsearch.index.query.QueryParseContext#parseInnerFilter()
The following examples show how to use
org.elasticsearch.index.query.QueryParseContext#parseInnerFilter() .
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: AliasValidator.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void validateAliasFilter(XContentParser parser, IndexQueryParserService indexQueryParserService) throws IOException { QueryParseContext context = indexQueryParserService.getParseContext(); try { context.reset(parser); context.parseInnerFilter(); } finally { context.reset(null); parser.close(); } }
Example 2
Source File: FunctionScoreQueryParser.java From Elasticsearch with Apache License 2.0 | 4 votes |
private String parseFiltersAndFunctions(QueryParseContext parseContext, XContentParser parser, ArrayList<FiltersFunctionScoreQuery.FilterFunction> filterFunctions, String currentFieldName) throws IOException { XContentParser.Token token; while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { Query filter = null; 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); } else { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (parseContext.parseFieldMatcher().match(currentFieldName, WEIGHT_FIELD)) { functionWeight = parser.floatValue(); } else { if ("filter".equals(currentFieldName)) { filter = parseContext.parseInnerFilter(); } else { // do not need to check null here, // functionParserMapper throws exception if parser // non-existent ScoreFunctionParser functionParser = functionParserMapper.get(parseContext, currentFieldName); scoreFunction = functionParser.parse(parseContext, parser); } } } if (functionWeight != null) { scoreFunction = new WeightFactorFunction(functionWeight, scoreFunction); } } if (filter == null) { filter = Queries.newMatchAllQuery(); } if (scoreFunction == null) { throw new ElasticsearchParseException("failed to parse [{}] query. an entry in functions list is missing a function.", NAME); } filterFunctions.add(new FiltersFunctionScoreQuery.FilterFunction(filter, scoreFunction)); } return currentFieldName; }