• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IndexFieldData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.index.fielddata.IndexFieldData的典型用法代码示例。如果您正苦于以下问题:Java IndexFieldData类的具体用法?Java IndexFieldData怎么用?Java IndexFieldData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IndexFieldData类属于org.elasticsearch.index.fielddata包,在下文中一共展示了IndexFieldData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: assertAvgScoreMode

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
protected void assertAvgScoreMode(Query parentFilter, IndexSearcher searcher, IndexFieldData.XFieldComparatorSource innerFieldComparator) throws IOException {
    MultiValueMode sortMode = MultiValueMode.AVG;
    Query childFilter = Queries.not(parentFilter);
    XFieldComparatorSource nestedComparatorSource = createFieldComparator("field2", sortMode, -127, createNested(searcher, parentFilter, childFilter));
    Query query = new ToParentBlockJoinQuery(new ConstantScoreQuery(childFilter), new QueryBitSetProducer(parentFilter), ScoreMode.None);
    Sort sort = new Sort(new SortField("field2", nestedComparatorSource));
    TopDocs topDocs = searcher.search(query, 5, sort);
    assertThat(topDocs.totalHits, equalTo(7));
    assertThat(topDocs.scoreDocs.length, equalTo(5));
    assertThat(topDocs.scoreDocs[0].doc, equalTo(11));
    assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(2));
    assertThat(topDocs.scoreDocs[1].doc, equalTo(7));
    assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[1]).fields[0]).intValue(), equalTo(2));
    assertThat(topDocs.scoreDocs[2].doc, equalTo(3));
    assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[2]).fields[0]).intValue(), equalTo(3));
    assertThat(topDocs.scoreDocs[3].doc, equalTo(15));
    assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[3]).fields[0]).intValue(), equalTo(3));
    assertThat(topDocs.scoreDocs[4].doc, equalTo(19));
    assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).intValue(), equalTo(3));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:FloatNestedSortingTests.java


示例2: getMethod

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
static ValueSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
    switch (method) {
        case GETVALUE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case ISEMPTY_METHOD:
            return new EmptyMemberValueSource(fieldData);
        case SIZE_METHOD:
            return new CountMethodValueSource(fieldData);
        case MINIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case MAXIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MAX);
        case AVERAGE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.AVG);
        case MEDIAN_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
        case SUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.SUM);
        case COUNT_METHOD:
            return new CountMethodValueSource(fieldData);
        case GET_YEAR_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.YEAR);
        case GET_MONTH_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MONTH);
        case GET_DAY_OF_MONTH_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.DAY_OF_MONTH);
        case GET_HOUR_OF_DAY_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.HOUR_OF_DAY);
        case GET_MINUTES_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MINUTE);
        case GET_SECONDS_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.SECOND);
        default:
            throw new IllegalArgumentException("Member method [" + method + "] does not exist for date field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:DateField.java


示例3: getMethod

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
static ValueSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
    switch (method) {
        case GETVALUE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case ISEMPTY_METHOD:
            return new EmptyMemberValueSource(fieldData);
        case SIZE_METHOD:
            return new CountMethodValueSource(fieldData);
        case MINIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case MAXIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MAX);
        case AVERAGE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.AVG);
        case MEDIAN_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
        case SUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.SUM);
        case COUNT_METHOD:
            return new CountMethodValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member method [" + method + "] does not exist for numeric field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:NumericField.java


示例4: build

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:27,代码来源:DocValuesIndexFieldData.java


示例5: get

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
/**
 * Instantiates a new reusable {@link BytesRefTermStream} based on the field type.
 */
public static BytesRefTermStream get(IndexReader reader, IndexFieldData indexFieldData) {
  if (indexFieldData instanceof IndexNumericFieldData) {
    IndexNumericFieldData numFieldData = (IndexNumericFieldData) indexFieldData;
    switch (numFieldData.getNumericType()) {

      case INT:
        return new IntegerBytesRefTermStream(reader, numFieldData);

      case LONG:
        return new LongBytesRefTermStream(reader, numFieldData);

      default:
        throw new UnsupportedOperationException("Streaming numeric type '" + numFieldData.getNumericType().name() + "' is unsupported");

    }
  }
  else {
    return new BytesBytesRefTermStream(reader, indexFieldData);
  }
}
 
开发者ID:sirensolutions,项目名称:siren-join,代码行数:24,代码来源:BytesRefTermStream.java


示例6: getVariable

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
static ValueSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
    switch (variable) {
        case VALUE_VARIABLE:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case EMPTY_VARIABLE:
            return new EmptyMemberValueSource(fieldData);
        case LENGTH_VARIABLE:
            return new CountMethodValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for date field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:DateField.java


示例7: getVariable

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
static ValueSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
    switch (variable) {
        case VALUE_VARIABLE:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case EMPTY_VARIABLE:
            return new EmptyMemberValueSource(fieldData);
        case LENGTH_VARIABLE:
            return new CountMethodValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for " + 
                                               "numeric field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:NumericField.java


示例8: getVariable

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
static ValueSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
    switch (variable) {
        case EMPTY_VARIABLE:
            return new GeoEmptyValueSource(fieldData);
        case LAT_VARIABLE:
            return new GeoLatitudeValueSource(fieldData);
        case LON_VARIABLE:
            return new GeoLongitudeValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for geo field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:GeoField.java


示例9: getMethod

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
static ValueSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
    switch (method) {
        case ISEMPTY_METHOD:
            return new GeoEmptyValueSource(fieldData);
        case GETLAT_METHOD:
            return new GeoLatitudeValueSource(fieldData);
        case GETLON_METHOD:
            return new GeoLongitudeValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member method [" + method + "] does not exist for geo field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:GeoField.java


示例10: DateObjectValueSource

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
DateObjectValueSource(IndexFieldData<?> indexFieldData, MultiValueMode multiValueMode, 
                      String methodName, ToIntFunction<ReadableDateTime> function) {
    super(indexFieldData, multiValueMode);

    Objects.requireNonNull(methodName);

    this.methodName = methodName;
    this.function = function;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:DateObjectValueSource.java


示例11: DateMethodValueSource

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
DateMethodValueSource(IndexFieldData<?> indexFieldData, MultiValueMode multiValueMode, String methodName, int calendarType) {
    super(indexFieldData, multiValueMode);

    Objects.requireNonNull(methodName);

    this.methodName = methodName;
    this.calendarType = calendarType;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:DateMethodValueSource.java


示例12: bytesField

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
private ValuesSource bytesField() throws IOException {
    final IndexFieldData<?> indexFieldData = fieldContext().indexFieldData();
    ValuesSource dataSource;
    if (indexFieldData instanceof ParentChildIndexFieldData) {
        dataSource = new ValuesSource.Bytes.WithOrdinals.ParentChild((ParentChildIndexFieldData) indexFieldData);
    } else if (indexFieldData instanceof IndexOrdinalsFieldData) {
        dataSource = new ValuesSource.Bytes.WithOrdinals.FieldData((IndexOrdinalsFieldData) indexFieldData);
    } else {
        dataSource = new ValuesSource.Bytes.FieldData(indexFieldData);
    }
    if (script() != null) {
        dataSource = new ValuesSource.WithScript(dataSource, script());
    }
    return dataSource;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:ValuesSourceConfig.java


示例13: convertValueFromSortField

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
private static Object convertValueFromSortField(Object value, SortField sortField, DocValueFormat format) {
    if (sortField.getComparatorSource() instanceof IndexFieldData.XFieldComparatorSource) {
        IndexFieldData.XFieldComparatorSource cmpSource = (IndexFieldData.XFieldComparatorSource) sortField.getComparatorSource();
        return convertValueFromSortType(sortField.getField(), cmpSource.reducedType(), value, format);
    }
    return convertValueFromSortType(sortField.getField(), sortField.getType(), value, format);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:SearchAfterBuilder.java


示例14: build

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的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


示例15: doToFunction

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
@Override
protected ScoreFunction doToFunction(QueryShardContext context) {
    final MappedFieldType fieldType = context.getMapperService().fullName("_uid");
    if (fieldType == null) {
        // mapper could be null if we are on a shard with no docs yet, so this won't actually be used
        return new RandomScoreFunction();
    }
    final int salt = (context.index().getName().hashCode() << 10) | context.getShardId();
    final IndexFieldData<?> uidFieldData = context.getForField(fieldType);
    return new RandomScoreFunction(this.seed == null ? hash(context.nowInMillis()) : seed, salt, uidFieldData);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:RandomScoreFunctionBuilder.java


示例16: build

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的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


示例17: build

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的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


示例18: build

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:DocValuesIndexFieldData.java


示例19: fielddataBuilder

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
@Override
public IndexFieldData.Builder fielddataBuilder() {
    failIfNoDocValues();
    return new IndexFieldData.Builder() {
        @Override
        public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                CircuitBreakerService breakerService, MapperService mapperService) {
            final IndexNumericFieldData scaledValues = (IndexNumericFieldData) new DocValuesIndexFieldData.Builder()
                    .numericType(IndexNumericFieldData.NumericType.LONG)
                    .build(indexSettings, fieldType, cache, breakerService, mapperService);
            return new ScaledFloatIndexFieldData(scaledValues, scalingFactor);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:ScaledFloatFieldMapper.java


示例20: fielddataBuilder

import org.elasticsearch.index.fielddata.IndexFieldData; //导入依赖的package包/类
@Override
public IndexFieldData.Builder fielddataBuilder() {
    if (hasDocValues()) {
        return new DocValuesIndexFieldData.Builder();
    }
    assert indexOptions() != IndexOptions.NONE;
    if (fielddata) {
        return new PagedBytesIndexFieldData.Builder(TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
            TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
            TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE);
    }
    return super.fielddataBuilder();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:TypeFieldMapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Server类代码示例发布时间:2022-05-22
下一篇:
Java Permission类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap