bin/solr install-plugin deduplication
id
bin/post -c mycollection file1.json file2.json
http://localhost:8983/solr/mycollection/select?q=*:*&de-duplication=true&dedupe.field=field_name&dedupe.threshold=0.5
在上面的示例中,“mycollection”是集合名称,“field_name”是要进行去重的字段名称,“0.5”表示去重阈值。结果将只返回不同的记录,所有其他记录将被过滤掉。
SolrQuery query = new SolrQuery("*:*");
query.setParam("de-duplication", "true");
query.setParam("dedupe.field", "field_name");
query.setParam("dedupe.threshold", "0.5");
QueryResponse response = solrClient.query(query);
其中,“field_name”和“0.5”分别指示要用作唯一键的字段和去重阈值。