@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore Circuit Breaker final String fieldName = fieldType.name(); if (BINARY_INDEX_FIELD_NAMES.contains(fieldName)) { assert numericType == null; return new BinaryDVIndexFieldData(indexSettings.getIndex(), fieldName); } else if (numericType != null) { return new SortedNumericDVIndexFieldData(indexSettings.getIndex(), fieldName, numericType); } else { return new SortedSetDVOrdinalsIndexFieldData(indexSettings, cache, fieldName, breakerService, scriptFunction); } }
@Override public AtomicOrdinalsFieldData loadDirect(LeafReaderContext context) throws Exception { return load(context); }
if (context.reader().getFieldInfos().fieldInfo(getFieldName()) != null) { fieldFound = true; break;
@Override public Query rewrite(IndexReader reader) throws IOException { Query rewritten = super.rewrite(reader); if (rewritten != this) { return rewritten; } if (reader instanceof DirectoryReader) { IndexSearcher indexSearcher = new IndexSearcher(reader); indexSearcher.setQueryCache(null); indexSearcher.setSimilarity(similarity); IndexOrdinalsFieldData indexParentChildFieldData = fieldDataJoin.loadGlobal((DirectoryReader) reader); OrdinalMap ordinalMap = indexParentChildFieldData.getOrdinalMap(); return JoinUtil.createJoinQuery(joinField, innerQuery, toQuery, indexSearcher, scoreMode, ordinalMap, minChildren, maxChildren); } else { if (reader.leaves().isEmpty() && reader.numDocs() == 0) { // asserting reader passes down a MultiReader during rewrite which makes this // blow up since for this query to work we have to have a DirectoryReader otherwise // we can't load global ordinals - for this to work we simply check if the reader has no leaves // and rewrite to match nothing return new MatchNoDocsQuery(); } throw new IllegalStateException("can't load global ordinals for reader of type: " + reader.getClass() + " must be a DirectoryReader"); } }
if (context.reader().getFieldInfos().fieldInfo(getFieldNames().indexName()) != null) { fieldFound = true; break;
@Override public Query rewrite(IndexReader reader) throws IOException { Query rewritten = super.rewrite(reader); if (rewritten != this) { return rewritten; } if (reader instanceof DirectoryReader) { IndexSearcher indexSearcher = new IndexSearcher(reader); indexSearcher.setQueryCache(null); indexSearcher.setSimilarity(similarity); IndexOrdinalsFieldData indexParentChildFieldData = fieldDataJoin.loadGlobal((DirectoryReader) reader); OrdinalMap ordinalMap = indexParentChildFieldData.getOrdinalMap(); return JoinUtil.createJoinQuery(joinField, innerQuery, toQuery, indexSearcher, scoreMode, ordinalMap, minChildren, maxChildren); } else { if (reader.leaves().isEmpty() && reader.numDocs() == 0) { // asserting reader passes down a MultiReader during rewrite which makes this // blow up since for this query to work we have to have a DirectoryReader otherwise // we can't load global ordinals - for this to work we simply check if the reader has no leaves // and rewrite to match nothing return new MatchNoDocsQuery(); } throw new IllegalStateException("can't load global ordinals for reader of type: " + reader.getClass() + " must be a DirectoryReader"); } }
@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore Circuit Breaker final String fieldName = fieldType.name(); if (BINARY_INDEX_FIELD_NAMES.contains(fieldName)) { assert numericType == null; return new BinaryDVIndexFieldData(indexSettings.getIndex(), fieldName); } else if (numericType != null) { return new SortedNumericDVIndexFieldData(indexSettings.getIndex(), fieldName, numericType); } else { return new SortedSetDVOrdinalsIndexFieldData(indexSettings, cache, fieldName, breakerService, scriptFunction); } }
@Override public AtomicOrdinalsFieldData loadDirect(LeafReaderContext context) throws Exception { return load(context); }
@Override public SortField sortField(@Nullable Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) { XFieldComparatorSource source = new BytesRefFieldComparatorSource(this, missingValue, sortMode, nested); /** * Check if we can use a simple {@link SortedSetSortField} compatible with index sorting and * returns a custom sort field otherwise. */ if (nested != null || (sortMode != MultiValueMode.MAX && sortMode != MultiValueMode.MIN) || (source.sortMissingLast(missingValue) == false && source.sortMissingFirst(missingValue) == false)) { return new SortField(getFieldName(), source, reverse); } SortField sortField = new SortedSetSortField(fieldName, reverse, sortMode == MultiValueMode.MAX ? SortedSetSelector.Type.MAX : SortedSetSelector.Type.MIN); sortField.setMissingValue(source.sortMissingLast(missingValue) ^ reverse ? SortedSetSortField.STRING_LAST : SortedSetSortField.STRING_FIRST); return sortField; }
@Override public Query rewrite(IndexReader reader) throws IOException { Query rewritten = super.rewrite(reader); if (rewritten != this) { return rewritten; } if (reader instanceof DirectoryReader) { IndexSearcher indexSearcher = new IndexSearcher(reader); indexSearcher.setQueryCache(null); indexSearcher.setSimilarity(similarity); IndexOrdinalsFieldData indexParentChildFieldData = fieldDataJoin.loadGlobal((DirectoryReader) reader); OrdinalMap ordinalMap = indexParentChildFieldData.getOrdinalMap(); return JoinUtil.createJoinQuery(joinField, innerQuery, toQuery, indexSearcher, scoreMode, ordinalMap, minChildren, maxChildren); } else { if (reader.leaves().isEmpty() && reader.numDocs() == 0) { // asserting reader passes down a MultiReader during rewrite which makes this // blow up since for this query to work we have to have a DirectoryReader otherwise // we can't load global ordinals - for this to work we simply check if the reader has no leaves // and rewrite to match nothing return new MatchNoDocsQuery(); } throw new IllegalStateException("can't load global ordinals for reader of type: " + reader.getClass() + " must be a DirectoryReader"); } }
@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore Circuit Breaker final String fieldName = fieldType.name(); if (BINARY_INDEX_FIELD_NAMES.contains(fieldName)) { assert numericType == null; return new BinaryDVIndexFieldData(indexSettings.getIndex(), fieldName); } else if (numericType != null) { return new SortedNumericDVIndexFieldData(indexSettings.getIndex(), fieldName, numericType); } else { return new SortedSetDVOrdinalsIndexFieldData(indexSettings, cache, fieldName, breakerService, scriptFunction); } }
@Override public AtomicOrdinalsFieldData loadDirect(LeafReaderContext context) throws Exception { return load(context); }
if (context.reader().getFieldInfos().fieldInfo(getFieldName()) != null) { fieldFound = true; break;
@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore Circuit Breaker final String fieldName = fieldType.name(); if (BINARY_INDEX_FIELD_NAMES.contains(fieldName)) { assert numericType == null; return new BinaryDVIndexFieldData(indexSettings.getIndex(), fieldName); } else if (numericType != null) { return new SortedNumericDVIndexFieldData(indexSettings.getIndex(), fieldName, numericType); } else { return new SortedSetDVOrdinalsIndexFieldData(indexSettings, cache, fieldName, breakerService, scriptFunction); } }
@Override public AtomicOrdinalsFieldData loadDirect(LeafReaderContext context) throws Exception { return load(context); }
if (context.reader().getFieldInfos().fieldInfo(getFieldName()) != null) { fieldFound = true; break;
@Override public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore Circuit Breaker final Names fieldNames = fieldType.names(); final Settings fdSettings = fieldType.fieldDataType().getSettings(); final Map<String, Settings> filter = fdSettings.getGroups("filter"); if (filter != null && !filter.isEmpty()) { throw new IllegalArgumentException("Doc values field data doesn't support filters [" + fieldNames.fullName() + "]"); } if (BINARY_INDEX_FIELD_NAMES.contains(fieldNames.indexName())) { assert numericType == null; return new BinaryDVIndexFieldData(index, fieldNames, fieldType.fieldDataType()); } else if (numericType != null) { if (TimestampFieldMapper.NAME.equals(fieldNames.indexName()) || Version.indexCreated(indexSettings).onOrAfter(Version.V_1_4_0_Beta1)) { return new SortedNumericDVIndexFieldData(index, fieldNames, numericType, fieldType.fieldDataType()); } else { // prior to ES 1.4: multi-valued numerics were boxed inside a byte[] as BINARY return new BinaryDVNumericIndexFieldData(index, fieldNames, numericType, fieldType.fieldDataType()); } } else { return new SortedSetDVOrdinalsIndexFieldData(index, cache, indexSettings, fieldNames, breakerService, fieldType.fieldDataType()); } }
@Override public AtomicOrdinalsFieldData loadDirect(LeafReaderContext context) throws Exception { return load(context); }
if (context.reader().getFieldInfos().fieldInfo(getFieldName()) != null) { fieldFound = true; break;
@Override public SortField sortField(@Nullable Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) { XFieldComparatorSource source = new BytesRefFieldComparatorSource(this, missingValue, sortMode, nested); /** * Check if we can use a simple {@link SortedSetSortField} compatible with index sorting and * returns a custom sort field otherwise. */ if (nested != null || (sortMode != MultiValueMode.MAX && sortMode != MultiValueMode.MIN) || (source.sortMissingLast(missingValue) == false && source.sortMissingFirst(missingValue) == false)) { return new SortField(getFieldName(), source, reverse); } SortField sortField = new SortedSetSortField(fieldName, reverse, sortMode == MultiValueMode.MAX ? SortedSetSelector.Type.MAX : SortedSetSelector.Type.MIN); sortField.setMissingValue(source.sortMissingLast(missingValue) ^ reverse ? SortedSetSortField.STRING_LAST : SortedSetSortField.STRING_FIRST); return sortField; }