是否有任何插件允许在 Elasticsearch 上使用 LSH?如果是的话,你能指出我的位置并告诉我如何使用它吗? 谢谢
编辑: 我发现 ES 使用 MinHash 插件。我怎么能用这个比较文件呢?查找重复项的最佳设置是什么?
最佳答案
有一个 Elasticsearch MinHash Plugin .您可以在每次索引文档时使用它来提取 minhash 值,然后通过 minhash 查询该文档。
安装 MinHash 插件:
$ $ES_HOME/bin/plugin install org.codelibs/elasticsearch-minhash/2.3.1
在创建索引时添加一个 minhash 分析器:
$ curl -XPUT 'localhost:9200/my_index' -d '{ "index":{ "analysis":{ "analyzer":{ "minhash_analyzer":{ "type":"custom", "tokenizer":"standard", "filter":["minhash"] } } } } }'
将
minhash_value
字段放入索引映射中:$ 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" } } } }'
- 将文档添加到您使用 minhash 分析器创建的索引时,会自动计算 minhash 值。
一个。 Use More like this query可用于在
minhash_value
字段上进行“喜欢”搜索:GET /_search { "query": { "more_like_this" : { "fields" : ["minhash_value"], "like" : "KV5rsUfZpcZdVojpG8mHLA==", "min_term_freq" : 1, "max_query_terms" : 12 } } }
您也可以使用 fuzzy query但它接受与结果相差
2
(最大值)的查询。GET /_search { "query": { "fuzzy" : { "minhash_value" : "KV5rsUfZpcZdVojpG8mHLA==" } } }
您可以找到更多关于模糊查询的信息 here .
- 或者您可以在 elasicsearch 之外创建哈希值(编写代码以提取哈希值),每次索引文档时,您都可以运行代码并将哈希值附加到您正在索引的文档。然后使用 More Like This query 搜索哈希值或 Fuzzy query如上所述。
- 最后但同样重要的是,您可以像上面那样自己编写 elasticsearch 插件(适合您的哈希算法)并执行与上面相同的步骤。
关于elasticsearch - 局部敏感哈希 - Elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32777630/