当前位置: 首页>>代码示例>>Java>>正文


Java MappedFieldType.name方法代码示例

本文整理汇总了Java中org.elasticsearch.index.mapper.MappedFieldType.name方法的典型用法代码示例。如果您正苦于以下问题:Java MappedFieldType.name方法的具体用法?Java MappedFieldType.name怎么用?Java MappedFieldType.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.index.mapper.MappedFieldType的用法示例。


在下文中一共展示了MappedFieldType.name方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getForField

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType) {
    final String fieldName = fieldType.name();
    IndexFieldData.Builder builder = fieldType.fielddataBuilder();

    IndexFieldDataCache cache;
    synchronized (this) {
        cache = fieldDataCaches.get(fieldName);
        if (cache == null) {
            String cacheType = indexSettings.getValue(INDEX_FIELDDATA_CACHE_KEY);
            if (FIELDDATA_CACHE_VALUE_NODE.equals(cacheType)) {
                cache = indicesFieldDataCache.buildIndexFieldDataCache(listener, index(), fieldName);
            } else if ("none".equals(cacheType)){
                cache = new IndexFieldDataCache.None();
            } else {
                throw new IllegalArgumentException("cache type not supported [" + cacheType + "] for field [" + fieldName + "]");
            }
            fieldDataCaches.put(fieldName, cache);
        }
    }

    return (IFD) builder.build(indexSettings, fieldType, cache, circuitBreakerService, mapperService);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:IndexFieldDataService.java

示例2: build

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
public SortFieldAndFormat build(QueryShardContext context) throws IOException {
    if (DOC_FIELD_NAME.equals(fieldName)) {
        if (order == SortOrder.DESC) {
            return SORT_DOC_REVERSE;
        } else {
            return SORT_DOC;
        }
    } else {
        MappedFieldType fieldType = context.fieldMapper(fieldName);
        if (fieldType == null) {
            if (unmappedType != null) {
                fieldType = context.getMapperService().unmappedFieldType(unmappedType);
            } else {
                throw new QueryShardException(context, "No mapping found for [" + fieldName + "] in order to sort on");
            }
        }

        MultiValueMode localSortMode = null;
        if (sortMode != null) {
            localSortMode = MultiValueMode.fromString(sortMode.toString());
        }

        boolean reverse = (order == SortOrder.DESC);
        if (localSortMode == null) {
            localSortMode = reverse ? MultiValueMode.MAX : MultiValueMode.MIN;
        }

        final Nested nested = resolveNested(context, nestedPath, nestedFilter);
        IndexFieldData<?> fieldData = context.getForField(fieldType);
        if (fieldData instanceof IndexNumericFieldData == false
                && (sortMode == SortMode.SUM || sortMode == SortMode.AVG || sortMode == SortMode.MEDIAN)) {
            throw new QueryShardException(context, "we only support AVG, MEDIAN and SUM on number based fields");
        }
        IndexFieldData.XFieldComparatorSource fieldComparatorSource = fieldData
                .comparatorSource(missing, localSortMode, nested);
        SortField field = new SortField(fieldType.name(), fieldComparatorSource, reverse);
        return new SortFieldAndFormat(field, fieldType.docValueFormat(null, null));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:FieldSortBuilder.java

示例3: resolveIndexName

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
private static String resolveIndexName(String fieldName, QueryShardContext context) {
    MappedFieldType fieldType = context.fieldMapper(fieldName);
    if (fieldType != null) {
        return fieldType.name();
    }
    return fieldName;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:SimpleQueryStringBuilder.java

示例4: doToQuery

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
    String field;
    MappedFieldType fieldType = context.fieldMapper(fieldName);
    if (fieldType != null) {
        field = fieldType.name();
    } else {
        field = fieldName;
    }

    Analyzer analyzerObj;
    if (analyzer == null) {
        if (fieldType != null) {
            analyzerObj = context.getSearchAnalyzer(fieldType);
        } else {
            analyzerObj = context.getMapperService().searchAnalyzer();
        }
    } else {
        analyzerObj = context.getMapperService().getIndexAnalyzers().get(analyzer);
        if (analyzerObj == null) {
            throw new QueryShardException(context, "[common] analyzer [" + analyzer + "] not found");
        }
    }

    Occur highFreqOccur = highFreqOperator.toBooleanClauseOccur();
    Occur lowFreqOccur = lowFreqOperator.toBooleanClauseOccur();

    ExtendedCommonTermsQuery commonsQuery = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur,
            cutoffFrequency, disableCoord, fieldType);
    return parseQueryString(commonsQuery, text, field, analyzerObj, lowFreqMinimumShouldMatch, highFreqMinimumShouldMatch);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:CommonTermsQueryBuilder.java

示例5: build

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
public IndexFieldData<?> build(IndexSettings indexSettings,
                               MappedFieldType fieldType,
                               IndexFieldDataCache cache, CircuitBreakerService breakerService,
                               MapperService mapperService) {
    return new ParentChildIndexFieldData(indexSettings, fieldType.name(), cache,
            mapperService, breakerService);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:ParentChildIndexFieldData.java

示例6: build

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    // Ignore breaker
    final String fieldName = fieldType.name();
    return new BytesBinaryDVIndexFieldData(indexSettings.getIndex(), fieldName);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:BytesBinaryDVIndexFieldData.java

示例7: doAssertLuceneQuery

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
protected void doAssertLuceneQuery(FieldMaskingSpanQueryBuilder queryBuilder, Query query, SearchContext context) throws IOException {
    String fieldInQuery = queryBuilder.fieldName();
    MappedFieldType fieldType = context.getQueryShardContext().fieldMapper(fieldInQuery);
    if (fieldType != null) {
        fieldInQuery = fieldType.name();
    }
    assertThat(query, instanceOf(FieldMaskingSpanQuery.class));
    FieldMaskingSpanQuery fieldMaskingSpanQuery = (FieldMaskingSpanQuery) query;
    assertThat(fieldMaskingSpanQuery.getField(), equalTo(fieldInQuery));
    assertThat(fieldMaskingSpanQuery.getMaskedQuery(), equalTo(queryBuilder.innerQuery().toQuery(context.getQueryShardContext())));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:FieldMaskingSpanQueryBuilderTests.java

示例8: build

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    // Ignore breaker
    return new GeoPointDVIndexFieldData(indexSettings.getIndex(), fieldType.name());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:AbstractGeoPointDVIndexFieldData.java

示例9: build

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    // ignore breaker
    return new LatLonPointDVIndexFieldData(indexSettings.getIndex(), fieldType.name());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:AbstractLatLonPointDVIndexFieldData.java

示例10: build

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
public IndexOrdinalsFieldData build(IndexSettings indexSettings, MappedFieldType fieldType,
                                                       IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
    return new PagedBytesIndexFieldData(indexSettings, fieldType.name(), cache, breakerService,
            minFrequency, maxFrequency, minSegmentSize);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:PagedBytesIndexFieldData.java

示例11: build

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
        CircuitBreakerService breakerService, MapperService mapperService) {
    return new IndexIndexFieldData(indexSettings, fieldType.name());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:IndexIndexFieldData.java

示例12: shardOperation

import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
protected AnalyzeResponse shardOperation(AnalyzeRequest request, ShardId shardId) {
    try {
        final IndexService indexService;
        if (shardId != null) {
            indexService = indicesService.indexServiceSafe(shardId.getIndex());
        } else {
            indexService = null;
        }
        String field = null;
        Analyzer analyzer = null;
        if (request.field() != null) {
            if (indexService == null) {
                throw new IllegalArgumentException("No index provided, and trying to analyzer based on a specific field which requires the index parameter");
            }
            MappedFieldType fieldType = indexService.mapperService().fullName(request.field());
            if (fieldType != null) {
                if (fieldType.tokenized()) {
                    analyzer = fieldType.indexAnalyzer();
                } else if (fieldType instanceof KeywordFieldMapper.KeywordFieldType) {
                    analyzer = ((KeywordFieldMapper.KeywordFieldType) fieldType).normalizer();
                    if (analyzer == null) {
                        // this will be KeywordAnalyzer
                        analyzer = fieldType.indexAnalyzer();
                    }
                } else {
                    throw new IllegalArgumentException("Can't process field [" + request.field() + "], Analysis requests are only supported on tokenized fields");
                }
                field = fieldType.name();
            }
        }
        if (field == null) {
            if (indexService != null) {
                field = indexService.getIndexSettings().getDefaultField();
            } else {
                field = AllFieldMapper.NAME;
            }
        }
        final AnalysisRegistry analysisRegistry = indicesService.getAnalysis();
        return analyze(request, field, analyzer, indexService != null ? indexService.getIndexAnalyzers() : null, analysisRegistry, environment);
    } catch (IOException e) {
        throw new ElasticsearchException("analysis failed", e);
    }

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:46,代码来源:TransportAnalyzeAction.java


注:本文中的org.elasticsearch.index.mapper.MappedFieldType.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。