/elasticsearch-hamming-plugin

hamming distance plugin for elasticsearch 5.x

Primary LanguageJavaApache License 2.0Apache-2.0

Elasticsearch Hamming Plugin

Install

$ cd /tmp 
$ wget https://github.com/joway/elasticsearch-hamming-plugin/raw/master/releases/elasticsearch-hamming-0.0.1.zip
$ /usr/share/elasticsearch/bin/elasticsearch-plugin  install  file://`pwd`/elasticsearch-hamming-0.0.1.zip
$ echo "script.inline: true" >> /etc/elasticsearch/elasticsearch.yml && echo "script.stored: true" >> /etc/elasticsearch/elasticsearch.yml

Usage

POST /{index_name}/_search :

{
  "query": {
    "function_score": {
      "query": {
        "match_all": {}
      },
      "functions": [
        {
          "script_score": {
            "script": {
              "inline": "hamming_distance_native",
              "lang": "native",
              "params": {
                "hash": "3dd3c609f30cd16c",
                "field": "phash"
              }
            }
          }
        }
      ]
    }
  }
}