Hi,
I am trying to create a mapping which will take image embeddings as input and should store in a field which will allow me to apply cosine or knn upon my request. I am trying to map a field with knn and coosine property in both.
To store image embeddings and perform cosine similarity or k-nearest neighbor (KNN) searches in Elasticsearch, use a dense_vector field in your mapping. This field type allows storing embeddings and supports cosine similarity out of the box. For KNN, you might need additional plugins, depending on your Elasticsearch version. Here's a quick guide:
Create an index with a dense_vector field for your embeddings, specifying the dimension size.
Index your image embeddings as dense vectors.
For cosine similarity, use a script_score query with a cosine similarity calculation to find similar images.
For KNN searches, your approach might vary based on Elasticsearch version and available plugins.
Remember, script-based similarity calculations can impact performance, so monitor and optimize your setup as needed.
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.