https://github.com/codelibs/elasticsearch-vector
Vector type and search functions for Elasticsearch
https://github.com/codelibs/elasticsearch-vector
Last synced: about 1 year ago
JSON representation
Vector type and search functions for Elasticsearch
- Host: GitHub
- URL: https://github.com/codelibs/elasticsearch-vector
- Owner: codelibs
- License: apache-2.0
- Created: 2019-06-30T21:45:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-05T18:20:25.000Z (over 3 years ago)
- Last Synced: 2025-03-30T18:04:37.818Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 60.5 KB
- Stars: 6
- Watchers: 7
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Elasticsearch Vector Plugin
=======================
## Overview
Vector Plugin provides bit\_vector type for searcing documents.
## Version
[Versions in Maven Repository](https://repo1.maven.org/maven2/org/codelibs/elasticsearch-vector/)
### Issues/Questions
Please file an [issue](https://github.com/codelibs/elasticsearch-vector/issues "issue").
## Installation
$ $ES_HOME/bin/elasticsearch-plugin install org.codelibs:elasticsearch-vector:7.5.0
## Getting Started
### Set Vector Field Type
This plugin provides the following field type:
- bit\_vector
```
$ curl -XPUT 'localhost:9200/my_index' -d '{
{
"mappings": {
"properties": {
"my_vector": {
"type": "bit_vector"
},
"my_text" : {
"type" : "keyword"
}
}
}
}'
```
### Add Vector Data
```
$ curl -XPUT "localhost:9200/my_index/_doc/1" -d '{
{
"my_text" : "text1",
"my_vector" : [0, 1, 1]
}'
```
### Search By Vectors
This plugin provides the following metrics functions:
- pairwiseHammingDistance
For examples, the usage is:
```
curl -s -XPOST "localhost:9200/my_index/_search?pretty" -H "Content-Type: application/json" -d "
{
\"query\": {
\"script_score\": {
\"query\": {
\"match_all\": {}
},
\"script\": {
\"source\": \"pairwiseHammingDistance(params.query_vector, doc['my_bit_vector'], true)\",
\"params\": {
\"query_vector\": [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]
}
}
}
}
}"
```