@Override public MapperService mapperService() { return in.mapperService(); }
private Map<String, DocumentField> getSearchFields(SearchContext context, FieldsVisitor fieldsVisitor, int subDocId, Map<String, Set<String>> storedToRequestedFields, LeafReaderContext subReaderContext) { loadStoredFields(context, subReaderContext, fieldsVisitor, subDocId); fieldsVisitor.postProcess(context.mapperService()); if (fieldsVisitor.fields().isEmpty()) { return null; } Map<String, DocumentField> searchFields = new HashMap<>(fieldsVisitor.fields().size()); for (Map.Entry<String, List<Object>> entry : fieldsVisitor.fields().entrySet()) { String storedField = entry.getKey(); List<Object> storedValues = entry.getValue(); if (storedToRequestedFields.containsKey(storedField)) { for (String requestedField : storedToRequestedFields.get(storedField)) { searchFields.put(requestedField, new DocumentField(requestedField, storedValues)); } } else { searchFields.put(storedField, new DocumentField(storedField, storedValues)); } } return searchFields; }
public final void build(SearchContext parentSearchContext, InnerHitsContext innerHitsContext) throws IOException { long innerResultWindow = innerHitBuilder.getFrom() + innerHitBuilder.getSize(); int maxInnerResultWindow = parentSearchContext.mapperService().getIndexSettings().getMaxInnerResultWindow(); if (innerResultWindow > maxInnerResultWindow) { throw new IllegalArgumentException( "Inner result window is too large, the inner hit definition's [" + innerHitBuilder.getName() + "]'s from + size must be less than or equal to: [" + maxInnerResultWindow + "] but was [" + innerResultWindow + "]. This limit can be set by changing the [" + IndexSettings.MAX_INNER_RESULT_WINDOW_SETTING.getKey() + "] index level setting." ); } doBuild(parentSearchContext, innerHitsContext); }
public ReverseNestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper, SearchContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, context, parent, pipelineAggregators, metaData); if (objectMapper == null) { parentFilter = Queries.newNonNestedFilter(context.mapperService().getIndexSettings().getIndexVersionCreated()); } else { parentFilter = objectMapper.nestedTypeFilter(); } parentBitsetProducer = context.bitsetFilterCache().getBitSetProducer(parentFilter); }
NestedAggregator(String name, AggregatorFactories factories, ObjectMapper parentObjectMapper, ObjectMapper childObjectMapper, SearchContext context, Aggregator parentAggregator, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData, boolean collectsFromSingleBucket) throws IOException { super(name, factories, context, parentAggregator, pipelineAggregators, metaData); Query parentFilter = parentObjectMapper != null ? parentObjectMapper.nestedTypeFilter() : Queries.newNonNestedFilter(context.mapperService().getIndexSettings().getIndexVersionCreated()); this.parentFilter = context.bitsetFilterCache().getBitSetProducer(parentFilter); this.childFilter = childObjectMapper.nestedTypeFilter(); this.collectsFromSingleBucket = collectsFromSingleBucket; }
FieldsVisitor rootFieldsVisitor = new FieldsVisitor(needSource); loadStoredFields(context, subReaderContext, rootFieldsVisitor, rootSubDocId); rootFieldsVisitor.postProcess(context.mapperService()); uid = rootFieldsVisitor.uid(); source = rootFieldsVisitor.source(); assert context.mapperService().types().size() == 1; typeText = context.mapperService().types().iterator().next(); DocumentMapper documentMapper = context.mapperService().documentMapper(typeText); SourceLookup sourceLookup = context.lookup().source(); sourceLookup.setSegmentAndDocument(subReaderContext, nestedSubDocId); assert nestedObjectMapper != null; SearchHit.NestedIdentity nestedIdentity = getInternalNestedIdentity(context, nestedSubDocId, subReaderContext, context.mapperService(), nestedObjectMapper); nestedObjectMapper.parentObjectMapperAreNested(context.mapperService()) == false) {
MapperService mapperService = context.mapperService(); Set<String> parentFields = new HashSet<>(); for (SearchHit hit : hits) {
private int findRootDocumentIfNested(SearchContext context, LeafReaderContext subReaderContext, int subDocId) throws IOException { if (context.mapperService().hasNested()) { BitSet bits = context.bitsetFilterCache() .getBitSetProducer(Queries.newNonNestedFilter(context.indexShard().indexSettings().getIndexVersionCreated())) .getBitSet(subReaderContext); if (!bits.get(subDocId)) { return bits.nextSetBit(subDocId); } } return -1; }
Collection<String> fieldNamesToHighlight; if (Regex.isSimpleMatchPattern(field.field())) { fieldNamesToHighlight = context.mapperService().simpleMatchToFullName(field.field()); } else { fieldNamesToHighlight = Collections.singletonList(field.field()); SourceFieldMapper sourceFieldMapper = context.mapperService().documentMapper(hitContext.hit().getType()).sourceMapper(); if (!sourceFieldMapper.enabled()) { throw new IllegalArgumentException("source is forced for fields " + fieldNamesToHighlight MappedFieldType fieldType = context.mapperService().fullName(fieldName); if (fieldType == null) { continue;
throws IOException { long innerResultWindow = from() + size(); int maxInnerResultWindow = context.mapperService().getIndexSettings().getMaxInnerResultWindow(); if (innerResultWindow > maxInnerResultWindow) { throw new IllegalArgumentException(
MappedFieldType fieldType = context.mapperService().fullName(field); if (fieldType != null) { final IndexFieldData<?> indexFieldData = context.getForField(fieldType);
ArrayList<TextFragment> fragsList = new ArrayList<>(); List<Object> textsToHighlight; Analyzer analyzer = HighlightUtils.getAnalyzer(context.mapperService().documentMapper(hitContext.hit().getType()), fieldType); final int maxAnalyzedOffset = context.indexShard().indexSettings().getHighlightMaxAnalyzedOffset();
try { final Analyzer analyzer = getAnalyzer(context.mapperService().documentMapper(hitContext.hit().getType()), fieldType); List<Object> fieldValues = loadFieldValues(fieldType, field, context, hitContext); if (fieldValues.size() == 0) {
Collection<String> fieldNames = context.mapperService().simpleMatchToFullName(fieldNameOrPattern); for (String fieldName : fieldNames) { MappedFieldType fieldType = context.smartNameFieldType(fieldName);
private SearchHit createSearchHit(SearchContext context, FieldsVisitor fieldsVisitor, int docId, int subDocId, Map<String, Set<String>> storedToRequestedFields, LeafReaderContext subReaderContext) { if (fieldsVisitor == null) { return new SearchHit(docId); } Map<String, DocumentField> searchFields = getSearchFields(context, fieldsVisitor, subDocId, storedToRequestedFields, subReaderContext); DocumentMapper documentMapper = context.mapperService().documentMapper(fieldsVisitor.uid().type()); Text typeText; if (documentMapper == null) { typeText = new Text(fieldsVisitor.uid().type()); } else { typeText = documentMapper.typeText(); } SearchHit searchHit = new SearchHit(docId, fieldsVisitor.uid().id(), typeText, searchFields); // Set _source if requested. SourceLookup sourceLookup = context.lookup().source(); sourceLookup.setSegmentAndDocument(subReaderContext, subDocId); if (fieldsVisitor.source() != null) { sourceLookup.setSource(fieldsVisitor.source()); } return searchHit; }
@Override protected void doBuild(SearchContext parentSearchContext, InnerHitsContext innerHitsContext) throws IOException { if (parentSearchContext.mapperService().getIndexSettings().isSingleType()) { handleJoinFieldInnerHits(parentSearchContext, innerHitsContext); } else { handleParentFieldInnerHits(parentSearchContext, innerHitsContext); } }
@Override protected ValuesSourceConfig<WithOrdinals> resolveConfig(SearchContext context) { ValuesSourceConfig<WithOrdinals> config = new ValuesSourceConfig<>(ValuesSourceType.BYTES); if (context.mapperService().getIndexSettings().isSingleType()) { joinFieldResolveConfig(context, config); } else { parentFieldResolveConfig(context, config); } return config; }
public ReverseNestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper, SearchContext context, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, context, parent, pipelineAggregators, metaData); if (objectMapper == null) { parentFilter = Queries.newNonNestedFilter(context.mapperService().getIndexSettings().getIndexVersionCreated()); } else { parentFilter = objectMapper.nestedTypeFilter(); } parentBitsetProducer = context.bitsetFilterCache().getBitSetProducer(parentFilter); }
Engine.GetResult result = null; try { Term uidTerm = context.mapperService().createUidTerm(request.type(), request.id()); if (uidTerm == null) { return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), false);
private int findRootDocumentIfNested(SearchContext context, LeafReaderContext subReaderContext, int subDocId) throws IOException { if (context.mapperService().hasNested()) { BitSet bits = context.bitsetFilterCache() .getBitSetProducer(Queries.newNonNestedFilter(context.indexShard().indexSettings().getIndexVersionCreated())) .getBitSet(subReaderContext); if (!bits.get(subDocId)) { return bits.nextSetBit(subDocId); } } return -1; }