is there any plugin allowing LSH on Elasticsearch? If yes, could you point me to the location and tell me a little how to use it? Thanks
Edit: I found out that ES uses MinHash plugin. How could I compare documents to one another with this? What would be a good setting to find duplicates?
There is a Elasticsearch MinHash Plugin. You can use it to extract minhash value every time you index a document and query the document by minhash later.
Install MinHash plugin:
$ $ES_HOME/bin/plugin install org.codelibs/elasticsearch-minhash/2.3.1
Add a minhash analyzer when creating your index:
$ curl -XPUT 'localhost:9200/my_index' -d '{
"index":{
"analysis":{
"analyzer":{
"minhash_analyzer":{
"type":"custom",
"tokenizer":"standard",
"filter":["minhash"]
}
}
}
}
}'
Put minhash_value
field into an index mapping:
$ curl -XPUT "localhost:9200/my_index/my_type/_mapping" -d '{
"my_type":{
"properties":{
"message":{
"type":"string",
"copy_to":"minhash_value"
},
"minhash_value":{
"type":"minhash",
"minhash_analyzer":"minhash_analyzer"
}
}
}
}'
a. Use More like this query can be used to do "like" search on the minhash_value
field:
GET /_search
{
"query": {
"more_like_this" : {
"fields" : ["minhash_value"],
"like" : "KV5rsUfZpcZdVojpG8mHLA==",
"min_term_freq" : 1,
"max_query_terms" : 12
}
}
}
b. You can also use fuzzy query but it accepts the query to differ from the result by 2
(maximum).
GET /_search
{
"query": {
"fuzzy" : { "minhash_value" : "KV5rsUfZpcZdVojpG8mHLA==" }
}
}
You can find more about the fuzzy query here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With