@Override public AtomicFieldData load(LeafReaderContext context) { return new UidAtomicFieldData(prefix, idFieldData.load(context)); }
@Override public Explanation explainScore(int docId, Explanation subQueryScore) throws IOException { String field = fieldData == null ? null : fieldData.getFieldName(); return Explanation.match( (float) score(docId, subQueryScore.getValue()), "random score function (seed: " + originalSeed + ", field: " + field + ")"); } };
@Override public <FD extends AtomicFieldData, IFD extends IndexFieldData<FD>> FD load(LeafReaderContext context, IFD indexFieldData) throws Exception { return indexFieldData.loadDirect(context); }
throw new IllegalArgumentException("docvalues not found for index sort field:[" + sortSpec.field + "]"); sortFields[i] = fieldData.sortField(sortSpec.missingValue, mode, null, reverse); validateIndexSortField(sortFields[i]);
@Override public void clear() { idFieldData.clear(); }
@Override public Post post() { // TODO would we need to implement filtering separately at this stage? From SearchContext? //check the data type of the field //if it is numeric, get the type and pass the information to the PostExecutor //otherwise, handle strings final boolean numericField = (_indexFieldData instanceof IndexNumericFieldData); FIELD_DATA_TYPE type = FIELD_DATA_TYPE.STRING; if(numericField) { final IndexNumericFieldData<?> indexNumericFieldData = (IndexNumericFieldData<?>) _indexFieldData; if(indexNumericFieldData.getNumericType() == IndexNumericFieldData.NumericType.LONG) type = FIELD_DATA_TYPE.LONG; if(indexNumericFieldData.getNumericType() == IndexNumericFieldData.NumericType.INT) type = FIELD_DATA_TYPE.INT; } return new PostExecutor(_indexFieldData.getFieldNames().name(), numericField, type); //throw new UnsupportedOperationException("Post aggregation is not yet supported"); }
throw new QueryShardException(context, "we only support AVG, MEDIAN and SUM on number based fields"); SortField field = fieldData.sortField(missing, localSortMode, nested, reverse); return new SortFieldAndFormat(field, fieldType.docValueFormat(null, null));
@Override public void clear() { idFieldData.clear(); }
@Override public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldNames().indexName());
@Override public ScriptDocValues<?> run() { return fieldDataLookup.apply(fieldType).load(reader).getScriptValues(); } });
@Override public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName());
@Override public AtomicFieldData loadDirect(LeafReaderContext context) throws Exception { return new UidAtomicFieldData(prefix, idFieldData.loadDirect(context)); }
throw new IllegalArgumentException("docvalues not found for index sort field:[" + sortSpec.field + "]"); sortFields[i] = fieldData.sortField(sortSpec.missingValue, mode, null, reverse); validateIndexSortField(sortFields[i]);
@Override public void clear() { idFieldData.clear(); }
@Override public SortedBinaryDocValues bytesValues(LeafReaderContext context) { return indexFieldData.load(context).getBytesValues(); } }
@Override public String description() { return methodName + ": field(" + fieldData.getFieldName() + ")"; }
@Override public <FD extends AtomicFieldData, IFD extends IndexFieldData<FD>> FD load(final LeafReaderContext context, final IFD indexFieldData) throws Exception { final ShardId shardId = ShardUtils.extractShardId(context.reader()); final IndexReader.CacheHelper cacheHelper = context.reader().getCoreCacheHelper(); if (cacheHelper == null) { throw new IllegalArgumentException("Reader " + context.reader() + " does not support caching"); } final Key key = new Key(this, cacheHelper.getKey(), shardId); //noinspection unchecked final Accountable accountable = cache.computeIfAbsent(key, k -> { cacheHelper.addClosedListener(IndexFieldCache.this); Collections.addAll(k.listeners, this.listeners); final AtomicFieldData fieldData = indexFieldData.loadDirect(context); for (Listener listener : k.listeners) { try { listener.onCache(shardId, fieldName, fieldData); } catch (Exception e) { // load anyway since listeners should not throw exceptions logger.error("Failed to call listener on atomic field data loading", e); } } return fieldData; }); return (FD) accountable; }
throw new IllegalArgumentException("docvalues not found for index sort field:[" + sortSpec.field + "]"); sortFields[i] = fieldData.sortField(sortSpec.missingValue, mode, null, reverse); validateIndexSortField(sortFields[i]);
protected SortedBinaryDocValues getValues(LeafReaderContext context) throws IOException { return indexFieldData.load(context).getBytesValues(); }
@Override public String description() { return "count: field(" + fieldData.getFieldName() + ")"; } }