@Override public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType) { return queryShardContext.getForField(fieldType); }
@Override protected ScoreFunction doToFunction(QueryShardContext context) { MappedFieldType fieldType = context.getMapperService().fullName(field); IndexNumericFieldData fieldData = null; if (fieldType == null) { if(missing == null) { throw new ElasticsearchException("Unable to find a field mapper for field [" + field + "]. No 'missing' value defined."); } } else { fieldData = context.getForField(fieldType); } return new FieldValueFactorFunction(field, factor, modifier, missing, fieldData); }
private LongValuesSource createValuesSource(QueryShardContext context) { LongValuesSource longValuesSource; if (minimumShouldMatchField != null) { MappedFieldType msmFieldType = context.fieldMapper(minimumShouldMatchField); if (msmFieldType == null) { throw new QueryShardException(context, "failed to find minimum_should_match field [" + minimumShouldMatchField + "]"); } IndexNumericFieldData fieldData = context.getForField(msmFieldType); longValuesSource = new FieldValuesSource(fieldData); } else if (minimumShouldMatchScript != null) { TermsSetQueryScript.Factory factory = context.getScriptService().compile(minimumShouldMatchScript, TermsSetQueryScript.CONTEXT); Map<String, Object> params = new HashMap<>(); params.putAll(minimumShouldMatchScript.getParams()); params.put("num_terms", values.size()); longValuesSource = new ScriptLongValueSource(minimumShouldMatchScript, factory.newFactory(params, context.lookup())); } else { throw new IllegalStateException("No minimum should match has been specified"); } return longValuesSource; }
DecayFunctionBuilder.ORIGIN); IndexNumericFieldData numericFieldData = context.getForField(fieldType); return new NumericFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), numericFieldData, mode);
IndexGeoPointFieldData indexFieldData = context.getForField(fieldType); return new GeoFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), indexFieldData, mode);
val = TimeValue.parseTimeValue(offsetString, TimeValue.timeValueHours(24), DecayFunctionParser.class.getSimpleName() + ".offset"); double offset = val.getMillis(); IndexNumericFieldData numericFieldData = context.getForField(dateFieldType); return new NumericFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), numericFieldData, mode);
@Override public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType) { return queryShardContext.getForField(fieldType); }
@Override public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType) { return queryShardContext.getForField(fieldType); }
@Override public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType) { return queryShardContext.getForField(fieldType); }
seed = hash(context.nowInMillis()); return new RandomScoreFunction(seed, salt, context.getForField(fieldType));
final IndexGeoPointFieldData geoIndexFieldData = context.getForField(fieldType);
IndexFieldData<?> fieldData = context.getForField(fieldType); if (fieldData instanceof IndexNumericFieldData == false && (sortMode == SortMode.SUM || sortMode == SortMode.AVG || sortMode == SortMode.MEDIAN)) {
throw new IllegalArgumentException("cannot load numeric doc values on " + field); } else { IndexFieldData ifm = context.getForField(type); if (ifm instanceof IndexNumericFieldData == false) { throw new IllegalArgumentException("cannot load numeric doc values on " + field);
if (ft != null && reader != null) { Long anyInstant = null; final IndexNumericFieldData fieldData = context.getForField(ft); for (LeafReaderContext ctx : reader.leaves()) { AtomicNumericFieldData leafFD = fieldData.load(ctx);
@Override protected ScoreFunction doToFunction(QueryShardContext context) { MappedFieldType fieldType = context.getMapperService().fullName(field); IndexNumericFieldData fieldData = null; if (fieldType == null) { if(missing == null) { throw new ElasticsearchException("Unable to find a field mapper for field [" + field + "]. No 'missing' value defined."); } } else { fieldData = context.getForField(fieldType); } return new FieldValueFactorFunction(field, factor, modifier, missing, fieldData); }
@Override protected ScoreFunction doToFunction(QueryShardContext context) { MappedFieldType fieldType = context.getMapperService().fullName(field); IndexNumericFieldData fieldData = null; if (fieldType == null) { if(missing == null) { throw new ElasticsearchException("Unable to find a field mapper for field [" + field + "]. No 'missing' value defined."); } } else { fieldData = context.getForField(fieldType); } return new FieldValueFactorFunction(field, factor, modifier, missing, fieldData); }
@Override protected ScoreFunction doToFunction(QueryShardContext context) { MappedFieldType fieldType = context.getMapperService().fullName(field); IndexNumericFieldData fieldData = null; if (fieldType == null) { if(missing == null) { throw new ElasticsearchException("Unable to find a field mapper for field [" + field + "]. No 'missing' value defined."); } } else { fieldData = context.getForField(fieldType); } return new FieldValueFactorFunction(field, factor, modifier, missing, fieldData); }
/** * sub-tests that need a more complex mock can overwrite this */ protected QueryShardContext queryShardContextMock(MapperService mapperService, MappedFieldType[] fieldTypes, CircuitBreakerService circuitBreakerService) { QueryShardContext queryShardContext = mock(QueryShardContext.class); when(queryShardContext.getMapperService()).thenReturn(mapperService); for (MappedFieldType fieldType : fieldTypes) { when(queryShardContext.fieldMapper(fieldType.name())).thenReturn(fieldType); when(queryShardContext.getForField(fieldType)).then(invocation -> fieldType.fielddataBuilder(mapperService.getIndexSettings() .getIndex().getName()) .build(mapperService.getIndexSettings(), fieldType, new IndexFieldDataCache.None(), circuitBreakerService, mapperService)); } NestedScope nestedScope = new NestedScope(); when(queryShardContext.isFilter()).thenCallRealMethod(); Mockito.doCallRealMethod().when(queryShardContext).setIsFilter(Matchers.anyBoolean()); when(queryShardContext.nestedScope()).thenReturn(nestedScope); return queryShardContext; }
IndexFieldData<?> indexFieldData = context.getForField(fieldType);
@Override protected ScoreFunction doToFunction(QueryShardContext context) { final MappedFieldType fieldType; if (context.getIndexSettings().isSingleType()) { fieldType = context.getMapperService().fullName(IdFieldMapper.NAME); } else { fieldType = context.getMapperService().fullName(UidFieldMapper.NAME); } 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); }