Versions (relevant - OpenSearch/Dashboard/Server OS/Browser): 3.3
Describe the issue:
I want to create an index that will only be used for exact KNN search. While I plan to index millions of documents, at any given time I’ll only be searching over a subset of 5,000–10,000 documents (pre-filtering). Given this access pattern, I believe exact KNN search is sufficient — and by avoiding the overhead of an HNSW graph, I expected to reduce both index size and cost.
To test this, I created an index with the knn setting explicitly set to false:
PUT /test-exact-knn-index
{
"settings": {
"index": {
"knn": false,
"number_of_shards": 5,
"number_of_replicas": 1
}
},
"mappings": {
"properties": {
"id": {
"type": "keyword",
"doc_values": false
},
"text_embedding": {
"type": "knn_vector",
"dimension": 768,
"doc_values": false
},
"text": {
"type": "text"
}
}
}
}
Contrary to my expectation, I noticed that the size of the index is larger than before. All the values below are excluding the replica size.
- Size of index with
knnsettingtrueandin_memorymode: 164GB - Size of index with
knnsettingtrueandon_diskmode (with 32x compression): 105GB - Size of index with
knnsetting asfalse: 222GB
I initially noticed that the doc_values setting for the text_embedding field is set to true and thought that was the reason the size of the index is going up. I then tried to explicitly set it to false like above, but it still shows as true after the index is created.
Here are the index settings:
{
"test-exact-knn-index": {
"aliases": {},
"mappings": {
"properties": {
"id": {
"type": "keyword",
"doc_values": false
},
"text": {
"type": "text"
},
"text_embedding": {
"type": "knn_vector",
"doc_values": true,
"dimension": 768
}
}
},
"settings": {
"index": {
"replication": {
"type": "DOCUMENT"
},
"number_of_shards": "5",
"provided_name": "test-exact-knn-index",
"knn": "false",
"creation_date": "1771958779417",
"number_of_replicas": "1",
"uuid": "ARKqYReGRgsEGZcTNhQfEg",
"version": {
"created": "137247498"
}
}
}
}
}
Questions:
-
Why does the index size increase when
knnis set tofalse? Shouldn’t removing the HNSW graph reduce storage overhead? -
Is this the correct approach for configuring an index for only exact KNN search?
-
Why is
doc_valuesbeing forced totrueon theknn_vectorfield even when explicitly set tofalse? -
I also observed that enabling
on_diskmode (with 32x compression) reduces the index size from 164 GB to 105 GB, with all other settings being the same. My understanding ofon_diskmode is that it stores quantized vectors in memory and full-precision vectors on disk. If that’s the case, I would expect the total storage footprint to be slightly larger thanin_memorymode, since it now stores both the quantized and full-precision copies. Why doeson_diskmode result in a smaller index size compared toin_memorymode? Am I misunderstanding howon_diskmode manages vector storage?