• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java MultiValueMode类的典型用法和代码示例

java 1次浏览

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

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

示例1: assertAvgScoreMode

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的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: assertAvgScoreMode

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
protected void assertAvgScoreMode(Query parentFilter, IndexSearcher searcher) 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(3));
    assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[1]).fields[0]).intValue(), equalTo(3));
    assertThat(topDocs.scoreDocs[2].doc, equalTo(7));
    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(4));
}
 

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

示例3: getMethod

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的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

示例4: getLeafCollector

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {
    if (valuesSource == null) {
        return LeafBucketCollector.NO_OP_COLLECTOR;
}
    final BigArrays bigArrays = context.bigArrays();
    final SortedNumericDoubleValues allValues = valuesSource.doubleValues(ctx);
    final NumericDoubleValues values = MultiValueMode.MAX.select(allValues, Double.NEGATIVE_INFINITY);
    return new LeafBucketCollectorBase(sub, allValues) {

        @Override
        public void collect(int doc, long bucket) throws IOException {
            if (bucket >= maxes.size()) {
                long from = maxes.size();
                maxes = bigArrays.grow(maxes, bucket + 1);
                maxes.fill(from, maxes.size(), Double.NEGATIVE_INFINITY);
            }
            final double value = values.get(doc);
            double max = maxes.get(bucket);
            max = Math.max(max, value);
            maxes.set(bucket, max);
        }

    };
}
 

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

示例5: parseVariable

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
private AbstractDistanceScoreFunction parseVariable(String fieldName, XContentParser parser, QueryShardContext context,
        MultiValueMode mode) throws IOException {
    //the field must exist, else we cannot read the value for the doc later
    MappedFieldType fieldType = context.fieldMapper(fieldName);
    if (fieldType == null) {
        throw new ParsingException(parser.getTokenLocation(), "unknown field [{}]", fieldName);
    }

    // dates and time and geo need special handling
    parser.nextToken();
    if (fieldType instanceof DateFieldMapper.DateFieldType) {
        return parseDateVariable(parser, context, fieldType, mode);
    } else if (fieldType instanceof GeoPointFieldType) {
        return parseGeoVariable(parser, context, fieldType, mode);
    } else if (fieldType instanceof NumberFieldMapper.NumberFieldType) {
        return parseNumberVariable(parser, context, fieldType, mode);
    } else {
        throw new ParsingException(parser.getTokenLocation(), "field [{}] is of type [{}], but only numeric types are supported.",
                fieldName, fieldType);
    }
}
 

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

示例6: distance

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
@Override
protected NumericDoubleValues distance(LeafReaderContext context) {
    final MultiGeoPointValues geoPointValues = fieldData.load(context).getGeoPointValues();
    return mode.select(new MultiValueMode.UnsortedNumericDoubleValues() {
        @Override
        public int count() {
            return geoPointValues.count();
        }

        @Override
        public void setDocument(int docId) {
            geoPointValues.setDocument(docId);
        }

        @Override
        public double valueAt(int index) {
            GeoPoint other = geoPointValues.valueAt(index);
            return Math.max(0.0d,
                    distFunction.calculate(origin.lat(), origin.lon(), other.lat(), other.lon(), DistanceUnit.METERS) - offset);
        }
    }, 0.0);
}
 

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

示例7: AbstractDistanceScoreFunction

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public AbstractDistanceScoreFunction(double userSuppiedScale, double decay, double offset, DecayFunction func,
        MultiValueMode mode) {
    super(CombineFunction.MULTIPLY);
    this.mode = mode;
    if (userSuppiedScale <= 0.0) {
        throw new IllegalArgumentException(FunctionScoreQueryBuilder.NAME + " : scale must be > 0.0.");
    }
    if (decay <= 0.0 || decay >= 1.0) {
        throw new IllegalArgumentException(FunctionScoreQueryBuilder.NAME + " : decay must be in the range [0..1].");
    }
    this.scale = func.processScale(userSuppiedScale, decay);
    this.func = func;
    if (offset < 0.0d) {
        throw new IllegalArgumentException(FunctionScoreQueryBuilder.NAME + " : offset must be > 0.0");
    }
    this.offset = offset;
}
 

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

示例8: innerInnerBuild

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
@Override
protected MultiValuesSourceAggregatorFactory<Numeric, ?> innerInnerBuild(
    final SearchContext context,
    final List<NamedValuesSourceConfigSpec<Numeric>> configs, final MultiValueMode multiValueMode,
    final AggregatorFactory<?> parent, final Builder subFactoriesBuilder) throws IOException {
  if (this.inputs == null || this.inputs.length != configs.size() - 1) {
    throw new IllegalArgumentException(
        "[inputs] must have [" + (configs.size() - 1)
            + "] values as much as the number of feature fields: ["
            + this.name
            + "]");
  }
  return new PredictionAggregatorFactory(this.name, configs, multiValueMode, this.inputs,
      context,
      parent,
      subFactoriesBuilder, this.metaData);
}
 

开发者ID:scaleborn,
项目名称:elasticsearch-linear-regression,
代码行数:18,
代码来源:PredictionAggregationBuilder.java

示例9: getLeafCollector

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {
    if (valuesSource == null) {
        return LeafBucketCollector.NO_OP_COLLECTOR;
    }
    final BigArrays bigArrays = context.bigArrays();
    final SortedNumericDoubleValues allValues = valuesSource.doubleValues(ctx);
    final NumericDoubleValues values = MultiValueMode.MIN.select(allValues, Double.POSITIVE_INFINITY);
    return new LeafBucketCollectorBase(sub, allValues) {

        @Override
        public void collect(int doc, long bucket) throws IOException {
            if (bucket >= mins.size()) {
                long from = mins.size();
                mins = bigArrays.grow(mins, bucket + 1);
                mins.fill(from, mins.size(), Double.POSITIVE_INFINITY);
            }
            final double value = values.get(doc);
            double min = mins.get(bucket);
            min = Math.min(min, value);
            mins.set(bucket, min);
        }

    };
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:27,
代码来源:MinAggregator.java

示例10: parseVariable

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
private AbstractDistanceScoreFunction parseVariable(String fieldName, XContentParser parser, QueryParseContext parseContext, MultiValueMode mode) throws IOException {

        // now, the field must exist, else we cannot read the value for
        // the doc later
        MappedFieldType fieldType = parseContext.fieldMapper(fieldName);
        if (fieldType == null) {
            throw new QueryParsingException(parseContext, "unknown field [{}]", fieldName);
        }

        // dates and time need special handling
        parser.nextToken();
        if (fieldType instanceof DateFieldMapper.DateFieldType) {
            return parseDateVariable(fieldName, parser, parseContext, (DateFieldMapper.DateFieldType) fieldType, mode);
        } else if (fieldType instanceof GeoPointFieldMapper.GeoPointFieldType) {
            return parseGeoVariable(fieldName, parser, parseContext, (GeoPointFieldMapper.GeoPointFieldType) fieldType, mode);
        } else if (fieldType instanceof NumberFieldMapper.NumberFieldType) {
            return parseNumberVariable(fieldName, parser, parseContext, (NumberFieldMapper.NumberFieldType) fieldType, mode);
        } else {
            throw new QueryParsingException(parseContext, "field [{}] is of type [{}], but only numeric types are supported.", fieldName, fieldType);
        }
    }
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:22,
代码来源:DecayFunctionParser.java

示例11: distance

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
@Override
protected NumericDoubleValues distance(LeafReaderContext context) {
    final MultiGeoPointValues geoPointValues = fieldData.load(context).getGeoPointValues();
    return mode.select(new MultiValueMode.UnsortedNumericDoubleValues() {
        @Override
        public int count() {
            return geoPointValues.count();
        }

        @Override
        public void setDocument(int docId) {
            geoPointValues.setDocument(docId);
        }

        @Override
        public double valueAt(int index) {
            GeoPoint other = geoPointValues.valueAt(index);
            return Math.max(0.0d, distFunction.calculate(origin.lat(), origin.lon(), other.lat(), other.lon(), DistanceUnit.METERS) - offset);
        }
    }, 0.0);
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:22,
代码来源:DecayFunctionParser.java

示例12: AbstractDistanceScoreFunction

点赞 3

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public AbstractDistanceScoreFunction(double userSuppiedScale, double decay, double offset, DecayFunction func, MultiValueMode mode) {
    super(CombineFunction.MULT);
    this.mode = mode;
    if (userSuppiedScale <= 0.0) {
        throw new IllegalArgumentException(FunctionScoreQueryParser.NAME + " : scale must be > 0.0.");
    }
    if (decay <= 0.0 || decay >= 1.0) {
        throw new IllegalArgumentException(FunctionScoreQueryParser.NAME
                + " : decay must be in the range [0..1].");
    }
    this.scale = func.processScale(userSuppiedScale, decay);
    this.func = func;
    if (offset < 0.0d) {
        throw new IllegalArgumentException(FunctionScoreQueryParser.NAME + " : offset must be > 0.0");
    }
    this.offset = offset;
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:18,
代码来源:DecayFunctionParser.java

示例13: getVariable

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的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

示例14: getVariable

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的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

示例15: comparatorSource

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
@Override
public org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource comparatorSource(final Object missingValue, final MultiValueMode sortMode, Nested nested) {
    switch (numericType) {
    case FLOAT:
        return new FloatValuesComparatorSource(this, missingValue, sortMode, nested);
    case DOUBLE:
        return new DoubleValuesComparatorSource(this, missingValue, sortMode, nested);
    default:
        assert !numericType.isFloatingPoint();
        return new LongValuesComparatorSource(this, missingValue, sortMode, nested);
    }
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:13,
代码来源:BinaryDVNumericIndexFieldData.java

示例16: DateObjectValueSource

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的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

示例17: DateMethodValueSource

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的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

示例18: MatrixStatsAggregator

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public MatrixStatsAggregator(String name, Map<String, ValuesSource.Numeric> valuesSources, SearchContext context,
                             Aggregator parent, MultiValueMode multiValueMode, List<PipelineAggregator> pipelineAggregators,
                             Map<String,Object> metaData) throws IOException {
    super(name, context, parent, pipelineAggregators, metaData);
    if (valuesSources != null && !valuesSources.isEmpty()) {
        this.valuesSources = new NumericMultiValuesSource(valuesSources, multiValueMode);
        stats = context.bigArrays().newObjectArray(1);
    } else {
        this.valuesSources = null;
    }
}
 

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

示例19: MatrixStatsAggregatorFactory

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public MatrixStatsAggregatorFactory(String name,
        Map<String, ValuesSourceConfig<ValuesSource.Numeric>> configs, MultiValueMode multiValueMode,
        SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder,
        Map<String, Object> metaData) throws IOException {
    super(name, configs, context, parent, subFactoriesBuilder, metaData);
    this.multiValueMode = multiValueMode;
}
 

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

示例20: NumericMultiValuesSource

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public NumericMultiValuesSource(Map<String, ValuesSource.Numeric> valuesSources, MultiValueMode multiValueMode) {
    super(valuesSources, multiValueMode);
    if (valuesSources != null) {
        this.values = valuesSources.values().toArray(new ValuesSource.Numeric[0]);
    } else {
        this.values = new ValuesSource.Numeric[0];
    }
}
 

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

示例21: build

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的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

示例22: fromXContent

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
/**
 * Parses bodies of the kind
 *
 * <pre>
 * <code>
 * {
 *      "fieldname1" : {
 *          "origin" : "someValue",
 *          "scale" : "someValue"
 *      },
 *      "multi_value_mode" : "min"
 * }
 * </code>
 * </pre>
 */
@Override
public DFB fromXContent(QueryParseContext context) throws IOException, ParsingException {
    XContentParser parser = context.parser();
    String currentFieldName;
    XContentParser.Token token;
    MultiValueMode multiValueMode = DecayFunctionBuilder.DEFAULT_MULTI_VALUE_MODE;
    String fieldName = null;
    BytesReference functionBytes = null;
    while ((token = parser.nextToken()) == XContentParser.Token.FIELD_NAME) {
        currentFieldName = parser.currentName();
        token = parser.nextToken();
        if (token == XContentParser.Token.START_OBJECT) {
            fieldName = currentFieldName;
            XContentBuilder builder = XContentFactory.jsonBuilder();
            builder.copyCurrentStructure(parser);
            functionBytes = builder.bytes();
        } else if (MULTI_VALUE_MODE.match(currentFieldName)) {
            multiValueMode = MultiValueMode.fromString(parser.text());
        } else {
            throw new ParsingException(parser.getTokenLocation(), "malformed score function score parameters.");
        }
    }
    if (fieldName == null || functionBytes == null) {
        throw new ParsingException(parser.getTokenLocation(), "malformed score function score parameters.");
    }
    DFB functionBuilder = createFromBytes.apply(fieldName, functionBytes);
    functionBuilder.setMultiValueMode(multiValueMode);
    return functionBuilder;
}
 

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

示例23: DecayFunctionBuilder

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
/**
 * Read from a stream.
 */
protected DecayFunctionBuilder(StreamInput in) throws IOException {
    super(in);
    fieldName = in.readString();
    functionBytes = in.readBytesReference();
    multiValueMode = MultiValueMode.readMultiValueModeFrom(in);
}
 

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

示例24: setMultiValueMode

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public DFB setMultiValueMode(MultiValueMode multiValueMode) {
    if (multiValueMode == null) {
        throw new IllegalArgumentException("decay function: multi_value_mode must not be null");
    }
    this.multiValueMode = multiValueMode;
    return (DFB) this;
}
 

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

示例25: parseNumberVariable

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
private AbstractDistanceScoreFunction parseNumberVariable(XContentParser parser, QueryShardContext context,
        MappedFieldType fieldType, MultiValueMode mode) throws IOException {
    XContentParser.Token token;
    String parameterName = null;
    double scale = 0;
    double origin = 0;
    double decay = 0.5;
    double offset = 0.0d;
    boolean scaleFound = false;
    boolean refFound = false;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            parameterName = parser.currentName();
        } else if (DecayFunctionBuilder.SCALE.equals(parameterName)) {
            scale = parser.doubleValue();
            scaleFound = true;
        } else if (DecayFunctionBuilder.DECAY.equals(parameterName)) {
            decay = parser.doubleValue();
        } else if (DecayFunctionBuilder.ORIGIN.equals(parameterName)) {
            origin = parser.doubleValue();
            refFound = true;
        } else if (DecayFunctionBuilder.OFFSET.equals(parameterName)) {
            offset = parser.doubleValue();
        } else {
            throw new ElasticsearchParseException("parameter [{}] not supported!", parameterName);
        }
    }
    if (!scaleFound || !refFound) {
        throw new ElasticsearchParseException("both [{}] and [{}] must be set for numeric fields.", DecayFunctionBuilder.SCALE,
                DecayFunctionBuilder.ORIGIN);
    }
    IndexNumericFieldData numericFieldData = context.getForField(fieldType);
    return new NumericFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), numericFieldData, mode);
}
 

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

示例26: parseGeoVariable

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
private AbstractDistanceScoreFunction parseGeoVariable(XContentParser parser, QueryShardContext context,
        MappedFieldType fieldType, MultiValueMode mode) throws IOException {
    XContentParser.Token token;
    String parameterName = null;
    GeoPoint origin = new GeoPoint();
    String scaleString = null;
    String offsetString = "0km";
    double decay = 0.5;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            parameterName = parser.currentName();
        } else if (DecayFunctionBuilder.SCALE.equals(parameterName)) {
            scaleString = parser.text();
        } else if (DecayFunctionBuilder.ORIGIN.equals(parameterName)) {
            origin = GeoUtils.parseGeoPoint(parser);
        } else if (DecayFunctionBuilder.DECAY.equals(parameterName)) {
            decay = parser.doubleValue();
        } else if (DecayFunctionBuilder.OFFSET.equals(parameterName)) {
            offsetString = parser.text();
        } else {
            throw new ElasticsearchParseException("parameter [{}] not supported!", parameterName);
        }
    }
    if (origin == null || scaleString == null) {
        throw new ElasticsearchParseException("[{}] and [{}] must be set for geo fields.", DecayFunctionBuilder.ORIGIN,
                DecayFunctionBuilder.SCALE);
    }
    double scale = DistanceUnit.DEFAULT.parse(scaleString, DistanceUnit.DEFAULT);
    double offset = DistanceUnit.DEFAULT.parse(offsetString, DistanceUnit.DEFAULT);
    IndexGeoPointFieldData indexFieldData = context.getForField(fieldType);
    return new GeoFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), indexFieldData, mode);

}
 

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

示例27: comparatorSource

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
@Override
public org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource comparatorSource(Object missingValue, MultiValueMode sortMode, Nested nested) {
    switch (numericType) {
        case FLOAT:
            return new FloatValuesComparatorSource(this, missingValue, sortMode, nested);
        case DOUBLE:
            return new DoubleValuesComparatorSource(this, missingValue, sortMode, nested);
        default:
            assert !numericType.isFloatingPoint();
            return new LongValuesComparatorSource(this, missingValue, sortMode, nested);
    }
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:13,
代码来源:SortedNumericDVIndexFieldData.java

示例28: getOrdinalsValues

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
@Override
public SortedDocValues getOrdinalsValues(String type) {
    AtomicOrdinalsFieldData atomicFieldData = typeToIds.get(type);
    if (atomicFieldData != null) {
        return MultiValueMode.MIN.select(atomicFieldData.getOrdinalsValues());
    } else {
        return DocValues.emptySorted();
    }
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:10,
代码来源:ParentChildAtomicFieldData.java

示例29: testMultiValueAllSet

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public void testMultiValueAllSet() throws Exception {
    fillMultiValueAllSet();
    // the segments are force merged to a single segment so that the sorted binary doc values can be asserted within a single segment.
    // Previously we used the SlowCompositeReaderWrapper but this is an unideal solution so force merging is a better idea.
    writer.forceMerge(1);
    IndexFieldData indexFieldData = getForField("value");
    List<LeafReaderContext> readerContexts = refreshReader();
    for (LeafReaderContext readerContext : readerContexts) {
        AtomicFieldData fieldData = indexFieldData.load(readerContext);
        assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed()));

        SortedBinaryDocValues bytesValues = fieldData.getBytesValues();
        assertValues(bytesValues, 0, two(), four());
        assertValues(bytesValues, 1, one());
        assertValues(bytesValues, 2, three());

        IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer));
        TopFieldDocs topDocs = searcher.search(new MatchAllDocsQuery(), 10, new Sort(new SortField("value", indexFieldData.comparatorSource(null, MultiValueMode.MIN, null))));
        assertThat(topDocs.totalHits, equalTo(3));
        assertThat(topDocs.scoreDocs.length, equalTo(3));
        assertThat(topDocs.scoreDocs[0].doc, equalTo(1));
        assertThat(topDocs.scoreDocs[1].doc, equalTo(0));
        assertThat(topDocs.scoreDocs[2].doc, equalTo(2));

        topDocs = searcher.search(new MatchAllDocsQuery(), 10, new Sort(new SortField("value", indexFieldData.comparatorSource(null, MultiValueMode.MAX, null), true)));
        assertThat(topDocs.totalHits, equalTo(3));
        assertThat(topDocs.scoreDocs.length, equalTo(3));
        assertThat(topDocs.scoreDocs[0].doc, equalTo(0));
        assertThat(topDocs.scoreDocs[1].doc, equalTo(2));
        assertThat(topDocs.scoreDocs[2].doc, equalTo(1));
    }
}
 

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

示例30: getTopDocs

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
private TopDocs getTopDocs(IndexSearcher searcher, IndexFieldData<?> indexFieldData, String missingValue, MultiValueMode sortMode, int n, boolean reverse) throws IOException {
    Query parentFilter = new TermQuery(new Term("__type", "parent"));
    Query childFilter = new TermQuery(new Term("__type", "child"));
    XFieldComparatorSource nestedComparatorSource = indexFieldData.comparatorSource(missingValue, sortMode, createNested(searcher, parentFilter, childFilter));
    Query query = new ConstantScoreQuery(parentFilter);
    Sort sort = new Sort(new SortField("f", nestedComparatorSource, reverse));
    return searcher.search(query, n, sort);
}
 

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

示例31: BaseSamplingAggregator

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public BaseSamplingAggregator(final String name,
    final List<NamedValuesSourceSpec<Numeric>> valuesSources,
    final SearchContext context,
    final Aggregator parent, final MultiValueMode multiValueMode,
    final List<PipelineAggregator> pipelineAggregators,
    final Map<String, Object> metaData) throws IOException {
  super(name, context, parent, pipelineAggregators, metaData);
  if (valuesSources != null && !valuesSources.isEmpty()) {
    this.valuesSources = new NumericMultiValuesSource(valuesSources, multiValueMode);
    this.samplings = context.bigArrays().newObjectArray(1);
    this.fieldsCount = this.valuesSources.fieldNames().length;
  } else {
    this.valuesSources = null;
  }
}
 

开发者ID:scaleborn,
项目名称:elasticsearch-linear-regression,
代码行数:16,
代码来源:BaseSamplingAggregator.java

示例32: StatsAggregator

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public StatsAggregator(final String name,
    final List<NamedValuesSourceSpec<Numeric>> valuesSources,
    final SearchContext context,
    final Aggregator parent,
    final MultiValueMode multiValueMode,
    final List<PipelineAggregator> pipelineAggregators,
    final Map<String, Object> metaData) throws IOException {
  super(name, valuesSources, context, parent, multiValueMode, pipelineAggregators, metaData);
}
 

开发者ID:scaleborn,
项目名称:elasticsearch-linear-regression,
代码行数:10,
代码来源:StatsAggregator.java

示例33: StatsAggregatorFactory

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public StatsAggregatorFactory(String name,
    List<NamedValuesSourceConfigSpec<Numeric>> configs, MultiValueMode multiValueMode,
    SearchContext context, AggregatorFactory<?> parent,
    AggregatorFactories.Builder subFactoriesBuilder,
    Map<String, Object> metaData) throws IOException {
  super(name, configs, context, parent, subFactoriesBuilder, metaData);
  this.multiValueMode = multiValueMode;
}
 

开发者ID:scaleborn,
项目名称:elasticsearch-linear-regression,
代码行数:9,
代码来源:StatsAggregatorFactory.java

示例34: PredictionAggregator

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public PredictionAggregator(final String name,
    final List<NamedValuesSourceSpec<Numeric>> valuesSources,
    final SearchContext context,
    final Aggregator parent,
    final MultiValueMode multiValueMode,
    final double[] inputs, final List<PipelineAggregator> pipelineAggregators,
    final Map<String, Object> metaData) throws IOException {
  super(name, valuesSources, context, parent, multiValueMode, pipelineAggregators, metaData);
  this.inputs = inputs;
}
 

开发者ID:scaleborn,
项目名称:elasticsearch-linear-regression,
代码行数:11,
代码来源:PredictionAggregator.java

示例35: PredictionAggregatorFactory

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
public PredictionAggregatorFactory(final String name,
    final List<NamedValuesSourceConfigSpec<Numeric>> configs, final MultiValueMode multiValueMode,
    final double[] inputs, final SearchContext context, final AggregatorFactory<?> parent,
    final Builder subFactoriesBuilder,
    final Map<String, Object> metaData) throws IOException {
  super(name, configs, context, parent, subFactoriesBuilder, metaData);
  this.multiValueMode = multiValueMode;
  this.inputs = inputs;
}
 

开发者ID:scaleborn,
项目名称:elasticsearch-linear-regression,
代码行数:10,
代码来源:PredictionAggregatorFactory.java

示例36: parse

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
/**
 * Parses bodies of the kind
 *
 * <pre>
 * <code>
 * {
 *      "fieldname1" : {
 *          "origin" = "someValue",
 *          "scale" = "someValue"
 *      }
 *
 * }
 * </code>
 * </pre>
 *
 * */
@Override
public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException {
    String currentFieldName;
    XContentParser.Token token;
    AbstractDistanceScoreFunction scoreFunction;
    String multiValueMode = "MIN";
    XContentBuilder variableContent = XContentFactory.jsonBuilder();
    String fieldName = null;
    while ((token = parser.nextToken()) == XContentParser.Token.FIELD_NAME) {
        currentFieldName = parser.currentName();
        token = parser.nextToken();
        if (token == XContentParser.Token.START_OBJECT) {
            variableContent.copyCurrentStructure(parser);
            fieldName = currentFieldName;
        } else if (parseContext.parseFieldMatcher().match(currentFieldName, MULTI_VALUE_MODE)) {
            multiValueMode = parser.text();
        } else {
            throw new ElasticsearchParseException("malformed score function score parameters.");
        }
    }
    if (fieldName == null) {
        throw new ElasticsearchParseException("malformed score function score parameters.");
    }
    XContentParser variableParser = XContentFactory.xContent(variableContent.string()).createParser(variableContent.string());
    scoreFunction = parseVariable(fieldName, variableParser, parseContext, MultiValueMode.fromString(multiValueMode.toUpperCase(Locale.ROOT)));
    return scoreFunction;
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:44,
代码来源:DecayFunctionParser.java

示例37: parseGeoVariable

点赞 2

import org.elasticsearch.search.MultiValueMode; //导入依赖的package包/类
private AbstractDistanceScoreFunction parseGeoVariable(String fieldName, XContentParser parser, QueryParseContext parseContext,
        GeoPointFieldMapper.GeoPointFieldType fieldType, MultiValueMode mode) throws IOException {
    XContentParser.Token token;
    String parameterName = null;
    GeoPoint origin = new GeoPoint();
    String scaleString = null;
    String offsetString = "0km";
    double decay = 0.5;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            parameterName = parser.currentName();
        } else if (parameterName.equals(DecayFunctionBuilder.SCALE)) {
            scaleString = parser.text();
        } else if (parameterName.equals(DecayFunctionBuilder.ORIGIN)) {
            origin = GeoUtils.parseGeoPoint(parser);
        } else if (parameterName.equals(DecayFunctionBuilder.DECAY)) {
            decay = parser.doubleValue();
        } else if (parameterName.equals(DecayFunctionBuilder.OFFSET)) {
            offsetString = parser.text();
        } else {
            throw new ElasticsearchParseException("parameter [{}] not supported!", parameterName);
        }
    }
    if (origin == null || scaleString == null) {
        throw new ElasticsearchParseException("[{}] and [{}] must be set for geo fields.", DecayFunctionBuilder.ORIGIN, DecayFunctionBuilder.SCALE);
    }
    double scale = DistanceUnit.DEFAULT.parse(scaleString, DistanceUnit.DEFAULT);
    double offset = DistanceUnit.DEFAULT.parse(offsetString, DistanceUnit.DEFAULT);
    IndexGeoPointFieldData indexFieldData = parseContext.getForField(fieldType);
    return new GeoFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), indexFieldData, mode);

}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:33,
代码来源:DecayFunctionParser.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)