所以我尝试使用solr 6附带的Lingo聚类算法对solr搜索结果进行聚类。它完成了这项工作,但我需要它来检索文档ID(这里的ID称为P_ID)聚类结果。我一直在努力,没有任何运气,非常感谢任何帮助 这是solrconfig.xml文件
<lib dir="${solr.install.dir:../../..}/contrib/clustering/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../..}/dist/" regex="solr-clustering-\d.*\.jar" />
<requestHandler name="/clustering"
startup="lazy"
enable="${solr.clustering.enabled:true}"
class="solr.SearchHandler">
<lst name="defaults">
<bool name="clustering">true</bool>
<bool name="clustering.results">true</bool>
<bool name="carrot.produceSummary">true</bool>
<!-- Logical field to physical field mapping. -->
<str name="carrot.url">P_ID</str>
<str name="carrot.title">input</str>
<str name="carrot.snippet">input</str>
<!-- Configure any other request handler parameters. We will cluster the
top 100 search results so bump up the 'rows' parameter. -->
<str name="defType">edismax</str>
<str name="qf">
input^1.4
</str>
<str name="q.alt">*:*</str>
<str name="rows">100</str>
<str name="fl">*</str>
</lst>
<arr name="last-components">
<str>clustering</str>
</arr>
</requestHandler>
以下是我得到的结果:
{
"responseHeader":{
"status":0,
"QTime":24},
"response":{"numFound":16,"start":0,"docs":[
{
"date":"2016-09-18 13:50:07.0",
"input":"Text",
"type":"q",
"U_ID":2,
"P_ID":1,
"_version_":1548945773383647232},
{
"date":"2016-09-18 13:53:09.0",
"input":"Text 2",
"type":"q",
"U_ID":10,
"P_ID":2,
"_version_":1548945773385744384},
{
"date":"2016-09-18 14:20:29.0",
"input":"Text 3",
"type":"q",
"U_ID":12,
"P_ID":3,
"_version_":1548945773385744385},
{
"date":"2016-09-18 13:50:07.0",
"input":"Text 4",
"type":"q",
"U_ID":3,
"P_ID":4,
"_version_":1548945773385744386},
]
},
"clusters":[{
"labels":["label 1"],
"score":6.723284893605449,
"docs":["text ",
"Text 2",
"Text 4"
]},
{
"labels":["lable 2"],
"score":10.22078770519469,
"docs":["text 3",
"Text 2"
]},
{
"labels":["label 3"],
"score":8.32470981979922,
"docs":["text 1",
"text 3"
]},
]}
正如您所看到的,在&#34;集群&#34;它给了我群集和文档,但它没有给我文档ID,我甚至尝试将fl参数更改为P_ID(文档ID),但它没有工作。它甚至可以在响应部分显示P_ID值,但不在群集部分显示。
答案 0 :(得分:1)
好的所以我想出了一个满足我需要的解决方案。我需要做的就是将文档ID放在架构中的<uniqueKey></uniqueKey>
元素中。