When indexing all my data, I didn't set the type to "hnsw". Does this mean kNN will not work at all? Or lower accuracy? I'm trying to understand the impact before I spend the time reindexing.
"type": "hnsw" is the default (and the only value supported) for index_options on dense_vector field types. You don't have to explicitly set that on your index for knn to work.
The parameter that controls the indexing of the field (and thus, approximate knn search) is index (see dense_vector field type parameters).
Depending of the Elasticsearch version you used to create the index, it will be indexed by default (8.11 or higher) or not (8.10 and previous).
If you are using approximate kNN:
If you created your index before 8.11 and didn't have "index": true as a parameter for your dense_vector field type, you will need to create a new index and ensure your dense_vector field is indexed. You can use reindex for transferring your data to the new index.
If you created your index on version 8.11 or above, you don't need to do anything for approximate knn to work.
If you are using exact kNN, you need no index changes as you don't need your field to be indexed.
Very helpful thank you! I confirmed I have 8.11, so just to confirm, both of the index mappings below are essentially identical given the default settings.
From the knn point of view, they are equivalent as both are indexed explicitly.
The only change is m option in index_options that change from the default (16). It affects the internal HNSW structure, but doesn't affect the usage from the knn point of view.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.