public QueryShardContext(QueryShardContext source) { this(source.shardId, source.indexSettings, source.bitsetFilterCache, source.indexFieldDataService, source.mapperService, source.similarityService, source.scriptService, source.getXContentRegistry(), source.getWriteableRegistry(), source.client, source.reader, source.nowInMillis, source.clusterAlias); this.types = source.getTypes(); }
@Override public SuggestionContext build(QueryShardContext context) throws IOException { CompletionSuggestionContext suggestionContext = new CompletionSuggestionContext(context); // copy over common settings to each suggestion builder final MapperService mapperService = context.getMapperService(); populateCommonFields(mapperService, suggestionContext); suggestionContext.setSkipDuplicates(skipDuplicates); suggestionContext.setFuzzyOptions(fuzzyOptions); suggestionContext.setRegexOptions(regexOptions); if (shardSize != null) { suggestionContext.setShardSize(shardSize); } MappedFieldType mappedFieldType = mapperService.fullName(suggestionContext.getField()); if (mappedFieldType == null || mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType == false) { throw new IllegalArgumentException("Field [" + suggestionContext.getField() + "] is not a completion suggest field"); } if (mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType) { CompletionFieldMapper.CompletionFieldType type = (CompletionFieldMapper.CompletionFieldType) mappedFieldType; suggestionContext.setFieldType(type); if (type.hasContextMappings() && contextBytes != null) { Map<String, List<ContextMapping.InternalQueryContext>> queryContexts = parseContextBytes(contextBytes, context.getXContentRegistry(), type.getContextMappings()); suggestionContext.setQueryContexts(queryContexts); } else if (contextBytes != null) { throw new IllegalArgumentException("suggester [" + type.name() + "] doesn't expect any context"); } } assert suggestionContext.getFieldType() != null : "no completion field type set"; return suggestionContext; }
public QueryShardContext(QueryShardContext source) { this(source.shardId, source.indexSettings, source.bitsetFilterCache, source.indexFieldDataService, source.mapperService, source.similarityService, source.scriptService, source.getXContentRegistry(), source.client, source.reader, source.nowInMillis); this.types = source.getTypes(); }
final String querySource = scriptFactory.newInstance(vars).execute(); try (XContentParser parser = XContentFactory.xContent(querySource) .createParser(shardContext.getXContentRegistry(), LoggingDeprecationHandler.INSTANCE, querySource)) { QueryBuilder innerQueryBuilder = AbstractQueryBuilder.parseInnerQueryBuilder(parser); final ParsedQuery parsedQuery = shardContext.toQuery(innerQueryBuilder);
public QueryShardContext(QueryShardContext source) { this(source.shardId, source.indexSettings, source.bitsetFilterCache, source.indexFieldDataService, source.mapperService, source.similarityService, source.scriptService, source.getXContentRegistry(), source.getWriteableRegistry(), source.client, source.reader, source.nowInMillis, source.clusterAlias); this.types = source.getTypes(); }
public QueryShardContext(QueryShardContext source) { this(source.shardId, source.indexSettings, source.bitsetFilterCache, source.indexFieldDataService, source.mapperService, source.similarityService, source.scriptService, source.getXContentRegistry(), source.getWriteableRegistry(), source.client, source.reader, source.nowInMillis, source.clusterAlias); this.types = source.getTypes(); }
@Override public SuggestionContext build(QueryShardContext context) throws IOException { CompletionSuggestionContext suggestionContext = new CompletionSuggestionContext(context); // copy over common settings to each suggestion builder final MapperService mapperService = context.getMapperService(); populateCommonFields(mapperService, suggestionContext); suggestionContext.setSkipDuplicates(skipDuplicates); suggestionContext.setFuzzyOptions(fuzzyOptions); suggestionContext.setRegexOptions(regexOptions); if (shardSize != null) { suggestionContext.setShardSize(shardSize); } MappedFieldType mappedFieldType = mapperService.fullName(suggestionContext.getField()); if (mappedFieldType == null || mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType == false) { throw new IllegalArgumentException("Field [" + suggestionContext.getField() + "] is not a completion suggest field"); } if (mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType) { CompletionFieldMapper.CompletionFieldType type = (CompletionFieldMapper.CompletionFieldType) mappedFieldType; suggestionContext.setFieldType(type); if (type.hasContextMappings() && contextBytes != null) { Map<String, List<ContextMapping.InternalQueryContext>> queryContexts = parseContextBytes(contextBytes, context.getXContentRegistry(), type.getContextMappings()); suggestionContext.setQueryContexts(queryContexts); } else if (contextBytes != null) { throw new IllegalArgumentException("suggester [" + type.name() + "] doesn't expect any context"); } } assert suggestionContext.getFieldType() != null : "no completion field type set"; return suggestionContext; }
@Override public SuggestionContext build(QueryShardContext context) throws IOException { CompletionSuggestionContext suggestionContext = new CompletionSuggestionContext(context); // copy over common settings to each suggestion builder final MapperService mapperService = context.getMapperService(); populateCommonFields(mapperService, suggestionContext); suggestionContext.setSkipDuplicates(skipDuplicates); suggestionContext.setFuzzyOptions(fuzzyOptions); suggestionContext.setRegexOptions(regexOptions); if (shardSize != null) { suggestionContext.setShardSize(shardSize); } MappedFieldType mappedFieldType = mapperService.fullName(suggestionContext.getField()); if (mappedFieldType == null || mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType == false) { throw new IllegalArgumentException("Field [" + suggestionContext.getField() + "] is not a completion suggest field"); } if (mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType) { CompletionFieldMapper.CompletionFieldType type = (CompletionFieldMapper.CompletionFieldType) mappedFieldType; suggestionContext.setFieldType(type); if (type.hasContextMappings() && contextBytes != null) { Map<String, List<ContextMapping.InternalQueryContext>> queryContexts = parseContextBytes(contextBytes, context.getXContentRegistry(), type.getContextMappings()); suggestionContext.setQueryContexts(queryContexts); } else if (contextBytes != null) { throw new IllegalArgumentException("suggester [" + type.name() + "] doesn't expect any context"); } } assert suggestionContext.getFieldType() != null : "no completion field type set"; return suggestionContext; }
suggestionContext.setFieldType(type); if (type.hasContextMappings() && contextBytes != null) { try (XContentParser contextParser = XContentFactory.xContent(contextBytes).createParser(context.getXContentRegistry(), contextBytes)) { if (type.hasContextMappings() && contextParser != null) { if (contextBytes != null) { try (XContentParser contextParser = XContentFactory.xContent(contextBytes) .createParser(suggestionContext.getShardContext().getXContentRegistry(), contextBytes)) { contextParser.nextToken(); suggestionContext.setContextQueries(ContextQuery.parseQueries(type.getContextMapping(), contextParser));
XContent xContent = PercolatorFieldMapper.QUERY_BUILDER_CONTENT_TYPE.xContent(); try (XContentParser sourceParser = xContent .createParser(context.getXContentRegistry(), LoggingDeprecationHandler.INSTANCE, qbSource.bytes, qbSource.offset, qbSource.length)) { return parseQuery(context, mapUnmappedFieldsAsString, sourceParser);
XContent xContent = PercolatorFieldMapper.QUERY_BUILDER_CONTENT_TYPE.xContent(); try (XContentParser sourceParser = xContent .createParser(context.getXContentRegistry(), LoggingDeprecationHandler.INSTANCE, qbSource.bytes, qbSource.offset, qbSource.length)) { return parseQuery(context, mapUnmappedFieldsAsString, sourceParser);
final ExecutableScript executable = collateScript.apply(vars); final BytesReference querySource = (BytesReference) executable.run(); try (XContentParser parser = XContentFactory.xContent(querySource).createParser(shardContext.getXContentRegistry(), querySource)) { Optional<QueryBuilder> innerQueryBuilder = shardContext.newParseContext(parser).parseInnerQueryBuilder();
final String querySource = scriptFactory.newInstance(vars).execute(); try (XContentParser parser = XContentFactory.xContent(querySource) .createParser(shardContext.getXContentRegistry(), LoggingDeprecationHandler.INSTANCE, querySource)) { QueryBuilder innerQueryBuilder = AbstractQueryBuilder.parseInnerQueryBuilder(parser); final ParsedQuery parsedQuery = shardContext.toQuery(innerQueryBuilder);
final String querySource = scriptFactory.newInstance(vars).execute(); try (XContentParser parser = XContentFactory.xContent(querySource) .createParser(shardContext.getXContentRegistry(), LoggingDeprecationHandler.INSTANCE, querySource)) { QueryBuilder innerQueryBuilder = AbstractQueryBuilder.parseInnerQueryBuilder(parser); final ParsedQuery parsedQuery = shardContext.toQuery(innerQueryBuilder);