Created
April 25, 2025 23:58
-
-
Save xeraa/c6e0543e86bc3d63ea6972692e7173e8 to your computer and use it in GitHub Desktop.
Paginated vector search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE my-index | |
PUT my-index | |
{ | |
"mappings": { | |
"properties": { | |
"title": { | |
"type": "text" | |
}, | |
"title_vector": { | |
"type": "dense_vector" | |
} | |
} | |
} | |
} | |
GET my-index/_mapping | |
PUT my-index/_doc/1 | |
{ | |
"title": "foxes", | |
"title_vector": [0.1, 3.2, 2.1] | |
} | |
PUT my-index/_doc/2 | |
{ | |
"title": "dogs", | |
"title_vector": [0.1, 3.2, 1.1] | |
} | |
PUT my-index/_doc/3 | |
{ | |
"title": "cats", | |
"title_vector": [0.1, 3.2, 0.1] | |
} | |
GET my-index/_search | |
GET my-index/_search | |
{ | |
"size": 1, | |
"from": 0, | |
"query": { | |
"knn": { | |
"field": "title_vector", | |
"query_vector": [0.1, 3.2, 1.0], | |
"k": 10 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment