Module org.elasticsearch.server
Class AbstractHnswVectorsFormat
java.lang.Object
org.apache.lucene.codecs.KnnVectorsFormat
org.elasticsearch.index.codec.vectors.AbstractHnswVectorsFormat
- All Implemented Interfaces:
org.apache.lucene.util.NamedSPILoader.NamedSPI
- Direct Known Subclasses:
ES814HnswScalarQuantizedVectorsFormat,ES815HnswBitVectorsFormat,ES816HnswBinaryQuantizedVectorsFormat,ES818HnswBinaryQuantizedVectorsFormat,ES93HnswBinaryQuantizedVectorsFormat,ES93HnswScalarQuantizedVectorsFormat,ES93HnswVectorsFormat,ES94HnswScalarQuantizedVectorsFormat
public abstract class AbstractHnswVectorsFormat
extends org.apache.lucene.codecs.KnnVectorsFormat
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intThe number of candidate neighbors to track while searching the graph for each newly inserted node.static final intAlways build HNSW graph regardless of segment sizeprotected final intThe minimum expected search cost before building an HNSW graph becomes worthwhile.protected final intControls how many of the nearest neighbor candidates are connected to the new node.protected final org.apache.lucene.search.TaskExecutorprotected final intFields inherited from class org.apache.lucene.codecs.KnnVectorsFormat
DEFAULT_MAX_DIMENSIONS, EMPTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractHnswVectorsFormat(String name, int maxConn, int beamWidth, int numMergeWorkers, ExecutorService mergeExec, int hnswGraphThreshold) Constructs a format using the given graph construction parameters, merge settings, and HNSW graph threshold. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract org.apache.lucene.codecs.hnsw.FlatVectorsFormatintgetMaxDimensions(String fieldName) protected static intresolveThreshold(int threshold, int defaultThreshold) Resolves the HNSW graph threshold.toString()Methods inherited from class org.apache.lucene.codecs.KnnVectorsFormat
availableKnnVectorsFormats, fieldsReader, fieldsWriter, forName, getName, reloadKnnVectorsFormat
-
Field Details
-
maxConn
protected final int maxConnControls how many of the nearest neighbor candidates are connected to the new node. Defaults toLucene99HnswVectorsFormat.DEFAULT_MAX_CONN. SeeHnswGraphfor more details. -
beamWidth
protected final int beamWidthThe number of candidate neighbors to track while searching the graph for each newly inserted node. Defaults toLucene99HnswVectorsFormat.DEFAULT_BEAM_WIDTH. SeeHnswGraphfor details. -
numMergeWorkers
protected final int numMergeWorkers -
mergeExec
protected final org.apache.lucene.search.TaskExecutor mergeExec -
DEFAULT_HNSW_GRAPH_THRESHOLD
public static final int DEFAULT_HNSW_GRAPH_THRESHOLDAlways build HNSW graph regardless of segment size- See Also:
-
hnswGraphThreshold
protected final int hnswGraphThresholdThe minimum expected search cost before building an HNSW graph becomes worthwhile. Below this threshold, brute-force search is efficient enough that graph construction overhead isn't worthwhile.
-
-
Constructor Details
-
AbstractHnswVectorsFormat
protected AbstractHnswVectorsFormat(String name, int maxConn, int beamWidth, int numMergeWorkers, ExecutorService mergeExec, int hnswGraphThreshold) Constructs a format using the given graph construction parameters, merge settings, and HNSW graph threshold.- Parameters:
maxConn- the maximum number of connections to a node in the HNSW graphbeamWidth- the size of the queue maintained during graph construction.numMergeWorkers- number of workers (threads) that will be used when doing merge. If larger than 1, a non-nullExecutorServicemust be passed as mergeExecmergeExec- theExecutorServicethat will be used by ALL vector writers that are generated by this format to do the mergehnswGraphThreshold- the minimum expected search cost before building an HNSW graph; if negative, use format default
-
-
Method Details
-
resolveThreshold
protected static int resolveThreshold(int threshold, int defaultThreshold) Resolves the HNSW graph threshold. If the given threshold is negative (not set), returns the provided default. -
flatVectorsFormat
protected abstract org.apache.lucene.codecs.hnsw.FlatVectorsFormat flatVectorsFormat() -
getMaxDimensions
- Specified by:
getMaxDimensionsin classorg.apache.lucene.codecs.KnnVectorsFormat
-
toString
-