Solr分面是否可以合并多个字段,例如RMDB中多个列上的不同字段? [英] Is it possible to do Solr faceting combining multiple fields, like distinct on multiple columns in RMDB?

查看:84
本文介绍了Solr分面是否可以合并多个字段,例如RMDB中多个列上的不同字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想对文档中两个字段的组合进行分面.

Let's say I want to do faceting on the combination of two fields in my doc.

例如:

Field1  Field2
A        B
C        D
A        B
A        C
C        B
C        D

会有类似方面的结果

AB [2]
CD [2]
AC [1]
CB [1]

这可能吗?我的意思是即时转移,这意味着字段是随机选择的,因此无法在索引期间创建复制字段.

Is this possible? I mean on the fly, which means the fields are picked randomly, and therefore cannot create a copyfield during index.

推荐答案

您可以使用 Pivot Facets (在Solr 4.0上可用).

You can group two fields using the Pivot Facets which is available on the Solr 4.0.

您可以对索引运行以下查询以获取它.

You can run the following query on your index to get it.

http://localhost:8181/solr/collection1/select?q=*:*&facet=true&facet.pivot=field1,field2

然后,结果将类似于:

<lst name="facet_pivot">
  <arr name="field1,field2">
    <lst>
      <str name="field">field1</str>
      <str name="value">A</str>
      <int name="count">3</int>
      <arr name="pivot">
        <lst>
          <str name="field">field2</str>
          <str name="value">B</str>
          <int name="count">2</int>
        </lst>
        <lst>
          <str name="field">field2</str>
          <str name="value">C</str>
          <int name="count">1</int>
        </lst>
      </arr>
    </lst>
    <lst>
      <str name="field">field1</str>
      <str name="value">C</str>
      <int name="count">3</int>
      <arr name="pivot">
        <lst>
          <str name="field">field2</str>
          <str name="value">D</str>
          <int name="count">2</int>
        </lst>
        <lst>
          <str name="field">field2</str>
          <str name="value">B</str>
          <int name="count">1</int>
        </lst>
      </arr>
    </lst>
  </arr>
</lst>

这篇关于Solr分面是否可以合并多个字段,例如RMDB中多个列上的不同字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆