Package io.objectbox.annotation
Annotation Interface HnswIndex
Parameters to configure HNSW-based approximate nearest neighbor (ANN) search. Some of the parameters can influence
index construction and searching. Changing these values causes re-indexing, which can take a while due to the complex
nature of HNSW.
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionlong
Dimensions of vectors; vector data with fewer dimensions are ignored. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe distance type used for the HNSW index.SeeHnswFlags
.long
Aka "efConstruction": the number of neighbor searched for while indexing (default: 100).long
Aka "M": the max number of connections per node (default: 30).float
When repairing the graph after a node was removed, this gives the probability of adding backlinks to the repaired neighbors.long
A non-binding hint at the maximum size of the vector cache in KB (default: 2097152 or 2 GB/GiB).
-
Element Details
-
dimensions
long dimensionsDimensions of vectors; vector data with fewer dimensions are ignored. Vectors with more dimensions than specified here are only evaluated up to the given dimension value. Changing this value causes re-indexing.
-
-
-
neighborsPerNode
long neighborsPerNodeAka "M": the max number of connections per node (default: 30). Higher numbers increase the graph connectivity, which can lead to more accurate search results. However, higher numbers also increase the indexing time and resource usage. Try e.g. 16 for faster but less accurate results, or 64 for more accurate results. Changing this value causes re-indexing.- Default:
- 0L
-
indexingSearchCount
long indexingSearchCountAka "efConstruction": the number of neighbor searched for while indexing (default: 100). The higher the value, the more accurate the search, but the longer the indexing. If indexing time is not a major concern, a value of at least 200 is recommended to improve search quality. Changing this value causes re-indexing.- Default:
- 0L
-
flags
HnswFlags flagsSeeHnswFlags
.- Default:
- @io.objectbox.annotation.HnswFlags
-
distanceType
VectorDistanceType distanceTypeThe distance type used for the HNSW index. Changing this value causes re-indexing.- Default:
- DEFAULT
-
reparationBacklinkProbability
float reparationBacklinkProbabilityWhen repairing the graph after a node was removed, this gives the probability of adding backlinks to the repaired neighbors. The default is 1.0 (aka "always") as this should be worth a bit of extra costs as it improves the graph's quality.- Default:
- 1.0f
-
vectorCacheHintSizeKB
long vectorCacheHintSizeKBA non-binding hint at the maximum size of the vector cache in KB (default: 2097152 or 2 GB/GiB). The actual size max cache size may be altered according to device and/or runtime settings. The vector cache is used to store vectors in memory to speed up search and indexing.Note 1: cache chunks are allocated only on demand, when they are actually used. Thus, smaller datasets will use less memory.
Note 2: the cache is for one specific HNSW index; e.g. each index has its own cache.
Note 3: the memory consumption can temporarily exceed the cache size, e.g. for large changes, it can double due to multi-version transactions.
- Default:
- 0L
-