Skip to main content

build doc PyPI version License: MIT

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) where code can be a list, string or numpy array together with additional fields
    eh.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)

Metadata

Release files for elastichash 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elastichash 0.1.5
File Size Uploaded Provenance Actions
elastichash-0.1.5.tar.gz 13.4 kB Without provenance Details for elastichash-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for elastichash 0.1.5
File Interpreter ABI Platform Actions
elastichash-0.1.5-py3-none-any.whl Python 3 none any Details for elastichash-0.1.5-py3-none-any.whl

Total release size: 25.1 kB

Release files / elastichash-0.1.5.tar.gz

Download URL elastichash-0.1.5.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4df3d50f06121620e73f37d26b72a619e3c52679f2924be4f6a8d2e6829c26b3
BLAKE2b-256 checksum
How to use checksums
32f2baf772ed702b751505d726aeead76b799eeb032ea4eaed5745ffd8e3ff51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / elastichash-0.1.5-py3-none-any.whl

Download URL elastichash-0.1.5-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef166ae79441b0dac646f7ce1c0c143e88fafa40136c6fbf5e9c82ae3278ca4d
BLAKE2b-256 checksum
How to use checksums
fb030838c599778f68c1bf24542d75b10752473af39bd856778a203bcffcef3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for elastichash 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page