本文整理汇总了Java中org.elasticsearch.index.fielddata.IndexFieldData类的典型用法代码示例。如果您正苦于以下问题:Java IndexFieldData类的具体用法?Java IndexFieldData怎么用?Java IndexFieldData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexFieldData类属于org.elasticsearch.index.fielddata包,在下文中一共展示了IndexFieldData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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 + "].");
}
}
示例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 + "].");
}
}
示例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());
}
}
示例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);
}
}
示例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 + "].");
}
}
示例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 + "].");
}
}
示例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 + "].");
}
}
示例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 + "].");
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
}
示例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);
}