ElasticHash enables efficient similarity search for binary hash codes using Elasticsearch
Project description
ElasticHash
Introduction
ElasticHash implements efficient similarity search by using a two-stage method for efficiently searching binary hash codes using Elasticsearch. In the first stage, a coarse search based on short hash codes is performed using multi-index hashing and ES terms lookup of neighboring hash codes. In the second stage, the list of results is re-ranked by computing the Hamming distance on long hash codes.
The only requirement ist that binary codes to be indexed need to be 256 bits long as currently only 256 bit codes are supported.
For a whole image similarity search system, including model training and model serving, see https://github.com/umr-ds/ElasticHash.
Install
pip install elastichash
Usage
- Create an Elastisearch client to use it with ElasticHash
es = Elasticsearch(elasticsearch_endpoint) eh = ElasticHash(es)
- New items can be added by calling
add(code)
wherecode
can be a list, string or numpy array together with additional fieldseh.add(code, additional_fields={"image_path": "/path/to/an/image"})
- After adding a suffiently large amount of codes (e.g. 10,000),
decorrelate()
needs to be called to rearrange the binary hashcode permutations - To search documents by their hash code use
search(code)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for elastichash-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef166ae79441b0dac646f7ce1c0c143e88fafa40136c6fbf5e9c82ae3278ca4d |
|
MD5 | 0184fae063837cb4d219bf4005107aef |
|
BLAKE2b-256 | fb030838c599778f68c1bf24542d75b10752473af39bd856778a203bcffcef3f |