0

我喜欢在查询时引导 Solr 搜索结果。例如,我有三个频道productsfaqother_docs。所有这些都在同一个 Solr 核心中,并填充了相同的字段。我想要接受的是让 Solr 为我将结果“通道”分组。

样本数据库(csv):

id,channel,name,desc
1,product,Some product,This is an very cool product!
2,product,Other product,This is an other product!
3,faq,How to stuff,This time: Simply do it!
4,other_docs,Legal notice,All your base are belong to us!

想要的查询结果(xml):

<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="grouped">
  <lst name="channel">
    <int name="matches">3</int>
    <arr name="groups">
      <lst>
        <str name="groupValue">product</str>
        <result name="doclist" numFound="2" start="0">
          <doc>
            <str name="name">Some product</str>
            <str name="desc">This is an very cool product!</str></doc>
          <doc>
            <str name="name">Other product</str>
            <str name="desc">This is an other product!</str></doc>
        </result>
      </lst>
      <lst>
        <str name="groupValue">faq</str>
        <result name="doclist" numFound="1" start="0">
          <doc>
            <str name="name">How to stuff</str>
            <str name="desc">This time: Simply do it!</str></doc>
        </result>
      </lst>
    </arr>
  </lst>
</lst>
</response>

我如何接受这个?

4

1 回答 1

1

检查 SOLR 中的字段折叠功能

结果分组/字段折叠

于 2013-07-11T08:50:39.360 回答