
org.elasticsearch.search.lookup.FieldValues Maven / Gradle / Ivy
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.search.lookup;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.index.mapper.ValueFetcher;
import org.elasticsearch.index.query.SearchExecutionContext;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
/**
* Represents values for a given document
*/
public interface FieldValues {
/**
* Loads the values for the given document and passes them to the consumer
* @param lookup a search lookup to access values from
* @param ctx the LeafReaderContext containing the document
* @param doc the docid
* @param consumer called with each document value
*/
void valuesForDoc(SearchLookup lookup, LeafReaderContext ctx, int doc, Consumer consumer);
/**
* Creates a {@link ValueFetcher} that fetches values from a {@link FieldValues} instance
* @param fieldValues the source of the values
* @param context the search execution context
* @return the value fetcher
*/
static ValueFetcher valueFetcher(FieldValues> fieldValues, SearchExecutionContext context) {
return valueFetcher(fieldValues, v -> v, context);
}
/**
* Creates a {@link ValueFetcher} that fetches values from a {@link FieldValues} instance
* @param fieldValues the source of the values
* @param formatter a function to format the values
* @param context the search execution context
* @return the value fetcher
*/
static ValueFetcher valueFetcher(FieldValues> fieldValues, Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy