1

我想知道这是否可以使用solr 查询

  1. 需要考虑的两列:location1、location2
  2. 想在两列上做一个脸。

下面的查询将起作用:

http://localhost:8983/solr/select/? q=*:*&version=2.2&rows=0&facet=true&facet.field=location1&facet.field=location2

回复:

    <response>
        <lst name="responseHeader">
            <int name="status">0</int>
            <int name="QTime">13</int>
        </lst>
        <result name="response" numFound="7789" start="0"/>
        <lst name="facet_counts">
        <lst name="facet_queries"/>
        <lst name="facet_fields">
        <lst name="location1">
            <int name="Chicago">100</int>
            <int name="NewYork">50</int>
            <int name="Washington">30</int>
        </lst>
        <lst name="location2">
            <int name="Washington">200</int>
            <int name="Philadelphia">100</int>
            <int name="Chicago">50</int>
        </lst>
<response>

我需要的是对 location1 和 location2 进行分组并得到以下结果:

Washington  :230
Chicago     :50
Philadelphia:100
Washington  :30

目前我们在服务层做这件事。但这可以使用 solr 中的结果分组来完成吗?我的理解是结果分组提供了所有数据的聚合,但不进行方面主题聚合。

4

2 回答 2

0

您需要将两者都存储location1location2一个多值字段中,例如locations. 然后你可以发出这个方面查询来得到你想要的:

q=*:*&rows=0&facet=true&facet.field=locations
于 2013-03-01T14:39:52.603 回答
0

Solr 不支持对多值字段进行分组。

Support for grouping on a multi-valued field has not yet been implemented. 

您可能可以使用组合值在索引处创建一个新字段,并将这些字段用于分面。

编辑:- 使用复制字段将两个字段的内容复制到单个字段并对其执行构面。只需要架构更改和数据重新索引

于 2013-03-01T07:54:18.997 回答