# Fuzzy Hash plugins (Java API for custom types, mappings?)

**URL:** https://discuss.elastic.co/t/fuzzy-hash-plugins-java-api-for-custom-types-mappings/187866
**Category:** Elasticsearch
**Created:** [June 27, 2019, 2:17pm UTC](https://discuss.elastic.co/t/fuzzy-hash-plugins-java-api-for-custom-types-mappings/187866 "2019-06-27T14:17:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rjzak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjzak/32/48945_2.png) [@rjzak](https://discuss.elastic.co/u/rjzak)
#### Post date: [June 27, 2019, 2:17pm UTC](https://discuss.elastic.co/t/fuzzy-hash-plugins-java-api-for-custom-types-mappings/187866/1 "2019-06-27T14:17:36Z")

</div>

I'm interested in developing plugins for fuzzy hashes, including [ssdeep](https://ssdeep-project.github.io/ssdeep/index.html), [sdhash](http://roussev.net/sdhash/sdhash.html), and [LZJD](https://github.com/EdwardRaff/jLZJD). I did find something similar, an existing [ssdeep plugin for Elasticsearch in Python](https://github.com/intezer/ssdeep-elastic), but I'd prefer to write the code in Java, since it's likely faster, and some of the fuzzy hash code is in Java anyway.

I did find a plugin for [Murmur3](https://github.com/elastic/elasticsearch/blob/master/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java), which is similar. But I don't see how the API works for storing, querying with a hash to get similarity, and how to return similar documents and adding a new field which is the similarity value (integer between zero and 100).

I'm working on a project where I'd like to be able to find similar documents based on the fuzzy hash, and the documents are metadata for raw binary files. These fuzzy hashes would work for text documents too (ssdeep was developed to detect spam emails).

Is there an API document to handle custom fields, mappings, and adding to the search result JSON?

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 27, 2019, 3:37pm UTC](https://discuss.elastic.co/t/fuzzy-hash-plugins-java-api-for-custom-types-mappings/187866/2 "2019-06-27T15:37:10Z")

</div>

Hey,

I think your best bet is studying the murmur3 plugin, which implements a custom mapper. I am not a hundred percent sure what else is needed in your use-case and different to the murmur3 mapper, so some more information might be good.

But looking at the source and creating your own plugin from that as a base sounds like the best way to go forward, as there is no dedicated plugin documentation.

Also, other plugins might be a good thing to look at, see [https://www.elastic.co/guide/en/elasticsearch/plugins/7.2/api.html](https://www.elastic.co/guide/en/elasticsearch/plugins/7.2/api.html)

--Alex

---

<div class="post-metadata">

### Author: ![rjzak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjzak/32/48945_2.png) [@rjzak](https://discuss.elastic.co/u/rjzak)
#### Post date: [June 27, 2019, 9:33pm UTC](https://discuss.elastic.co/t/fuzzy-hash-plugins-java-api-for-custom-types-mappings/187866/3 "2019-06-27T21:33:43Z")

</div>

The Murmur3 example doesn't demonstrate how to perform an action on the hash. The Murmur3FieldType. termQuery() function throws an exception saying the field isn't searchable. I'd like to be able to query with an SSDeep or similar hash, have Elasticsearch perform the similarity comparison between the provided SSDeep hash and the SSDeep hash in each document in the index, and provide the document and similarity score for each document where the score is greater than zero.

I did find [this old SSDeep plugin](https://github.com/abreksa4/elasticsearch-ssdeep-plugin/blob/master/src/main/java/com/phishme/ssdeep/es/script/SSDeepSearchScript.java), which says it's for Elasticsearch 2. What's the difference between Script and Plugin?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 25, 2019, 9:40pm UTC](https://discuss.elastic.co/t/fuzzy-hash-plugins-java-api-for-custom-types-mappings/187866/4 "2019-07-25T21:40:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
