// id, title, and content are text fields.// num in image is the image number, such as the frame number (optional).// emb in image is the image embedding data; image = [image1_emb, image2_emb, image3_emb, ..., imagen_emb].PUT /image_embeddings{"mappings": {"properties": {"id": {"type": "keyword"},"title": {"type": "text"},"content": {"type": "text"},"image": {"type": "nested","properties": {"num": {"type": "keyword"},"emb": {"type": "dense_vector","dims": 5,"index_options": {"type": "int8_hnsw"},"similarity": "cosine"}}}}}}
POST /image_embeddings/_doc/1{"id": "book_001","title": "Sunny day","content": "On this windy day, I tried to hold your hand","image": [{"num": "0", "emb": [0.1,0.2,0.3,0.4,0.5]},{"num": "1", "emb": [0.6,0.7,0.8,0.9,1.0]},{"num": "2", "emb": [0.2,0.3,0.4,0.5,0.6]}]}POST /image_embeddings/_doc/2{"id": "book_002","title": "Heading north","content": "Heading north, I tried to hold your hand","image": [{"num": "0", "emb": [0.1,0.2,0.3,0.4,0.5]},{"num": "1", "emb": [0.6,0.7,0.8,0.9,1.0]}]}POST /image_embeddings/_doc/3{"id": "book_003","title": " Nunchaku","content": "Heng Heng Ha Hei","image": [{"num": "0", "emb": [0.1,0.2,0.3,0.4,0.5]},{"num": "1", "emb": [0.6,0.7,0.8,0.9,1.0]},{"num": "2", "emb": [0.1,0.2,0.3,0.4,0.5]},{"num": "3", "emb": [0.6,0.7,0.8,0.9,1.0]},{"num": "4", "emb": [0.1,0.2,0.3,0.4,0.5]},{"num": "5", "emb": [0.6,0.7,0.8,0.9,1.0]}]}
GET book-index/_search{"retriever": {"rrf": {"retrievers": [{"retriever": {"knn": {"field": "image.emb","query_vector": [0.1, 0.2, 0.3,0.4,0.5],"k": 5,"num_candidates": 50}},"weight": 0.8},{"retriever": {"standard": {"query": {"match": {"title": "Sunny day"}}}},"weight": 0.2}],"rank_window_size": 50,"rank_constant": 20}}}
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback