Skip to content

Instantly share code, notes, and snippets.

@xeraa
Created April 25, 2025 23:58
Show Gist options
  • Save xeraa/c6e0543e86bc3d63ea6972692e7173e8 to your computer and use it in GitHub Desktop.
Save xeraa/c6e0543e86bc3d63ea6972692e7173e8 to your computer and use it in GitHub Desktop.
Paginated vector search
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