Java Code Examples for org.elasticsearch.index.mapper.MappedFieldType#fieldDataType()

The following examples show how to use org.elasticsearch.index.mapper.MappedFieldType#fieldDataType() . 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: AbstractGeoPointDVIndexFieldData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    // Ignore breaker
    return new GeoPointDVIndexFieldData(index, fieldType.names(), fieldType.fieldDataType(),
            Version.indexCreated(indexSettings).before(Version.V_2_2_0));
}
 
Example 2
Source File: ParentChildIndexFieldData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType,
                               IndexFieldDataCache cache, CircuitBreakerService breakerService,
                               MapperService mapperService) {
    return new ParentChildIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache,
        mapperService, breakerService);
}
 
Example 3
Source File: BytesBinaryDVIndexFieldData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    // Ignore breaker
    final Names fieldNames = fieldType.names();
    return new BytesBinaryDVIndexFieldData(index, fieldNames, fieldType.fieldDataType());
}
 
Example 4
Source File: PackedArrayIndexFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public IndexFieldData<AtomicNumericFieldData> build(Index index, Settings indexSettings, MappedFieldType fieldType,
                                                    IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
    return new PackedArrayIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache, numericType, breakerService);
}
 
Example 5
Source File: DoubleArrayIndexFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    return new DoubleArrayIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache, breakerService);
}
 
Example 6
Source File: PagedBytesIndexFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public IndexOrdinalsFieldData build(Index index, Settings indexSettings, MappedFieldType fieldType,
                                                       IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
    return new PagedBytesIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache, breakerService);
}
 
Example 7
Source File: FloatArrayIndexFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    return new FloatArrayIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache, breakerService);
}
 
Example 8
Source File: GeoPointArrayIndexFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    return new GeoPointArrayIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache,
            breakerService);
}
 
Example 9
Source File: IndexFieldDataService.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType) {
    final Names fieldNames = fieldType.names();
    final FieldDataType type = fieldType.fieldDataType();
    if (type == null) {
        throw new IllegalArgumentException("found no fielddata type for field [" + fieldNames.fullName() + "]");
    }
    final boolean docValues = fieldType.hasDocValues();
    IndexFieldData.Builder builder = null;
    Settings indexSettings = indexSettings();
    String format = type.getFormat(indexSettings);
    if (format != null && FieldDataType.DOC_VALUES_FORMAT_VALUE.equals(format) && !docValues) {
        logger.warn("field [" + fieldNames.fullName() + "] has no doc values, will use default field data format");
        format = null;
    }
    if (format != null) {
        builder = buildersByTypeAndFormat.get(Tuple.tuple(type.getType(), format));
        if (builder == null) {
            logger.warn("failed to find format [" + format + "] for field [" + fieldNames.fullName() + "], will use default");
        }
    }
    if (builder == null && docValues) {
        builder = docValuesBuildersByType.get(type.getType());
    }
    if (builder == null) {
        builder = buildersByType.get(type.getType());
    }
    if (builder == null) {
        throw new IllegalArgumentException("failed to find field data builder for field " + fieldNames.fullName() + ", and type " + type.getType());
    }

    IndexFieldDataCache cache;
    synchronized (this) {
        cache = fieldDataCaches.get(fieldNames.indexName());
        if (cache == null) {
            //  we default to node level cache, which in turn defaults to be unbounded
            // this means changing the node level settings is simple, just set the bounds there
            String cacheType = type.getSettings().get("cache", indexSettings.get(FIELDDATA_CACHE_KEY, FIELDDATA_CACHE_VALUE_NODE));
            if (FIELDDATA_CACHE_VALUE_NODE.equals(cacheType)) {
                cache = indicesFieldDataCache.buildIndexFieldDataCache(listener, index, fieldNames, type);
            } else if ("none".equals(cacheType)){
                cache = new IndexFieldDataCache.None();
            } else {
                throw new IllegalArgumentException("cache type not supported [" + cacheType + "] for field [" + fieldNames.fullName() + "]");
            }
            fieldDataCaches.put(fieldNames.indexName(), cache);
        }

        // Remove this in 3.0
        final boolean isOldParentField = ParentFieldMapper.NAME.equals(fieldNames.indexName())
                && Version.indexCreated(indexSettings).before(Version.V_2_0_0_beta1);
        if (isOldParentField) {
            if (parentIndexFieldData == null) {
                parentIndexFieldData = builder.build(index, indexSettings, fieldType, cache, circuitBreakerService, mapperService);
            }
            return (IFD) parentIndexFieldData;
        }
    }

    return (IFD) builder.build(index, indexSettings, fieldType, cache, circuitBreakerService, mapperService);
}