Approaches to Hierarchical Facets in Solr 处理Solr中分层的Facets

This document contains various suggestions and solutions for dealing with"Hierarchical Facets" - a concept which can mean differnet things todiffernet people depending on their data.

本文档包含处理"Hierarchical Facets"的各种建议和解决方案-根据数据的不同,"Hierarchical Facets"对不同的人可能意味着不同的东西。

Contents

  1. Approaches to Hierarchical Facets in Solr
  2. 'facet.prefix' Based Drill Down
    1. Flattened Data “breadcrumbs”
    2. Indexed Terms
    3. Initial Query
    4. Drill Down
  3. PathHierarchyTokenizerFactory
    1. Flattened Data
    2. Output Tokens
    3. Initial Query
  4. Pivot Facets
    1. Flattened Data “breadcrumbs”
    2. Indexed Terms
  5. Strict hierarchical facets
  6. Multipath hierarchical faceting
  7. Faceting Module

'facet.prefix' Based Drill Down

基于‘facet.prefix’的深度探讨。

Solr1.2

Transcribed (with slight edits) from Mastering the Power of Faceted Search by Chris Hostetterof Lucid Imagination (starting ~28minin)

For simple categories, facet.field works fine as-is. However,categorization schemes are frequently organized in a hierarchically-structuredscheme, and the user experience for interacting with thattaxonomy involves drill down,startingat the top (more general) and whittling the way down (more specific).

对于简单的分类,facet.field能正常的工作。然而分类方案经常被组织成层次结构化的,而且深入发掘与分类进行交互的用户体验,开始在顶端(一般)并且在深入中削减(更具体)

This is a basic approach that works well for most usecases and takes advantage of basic Solr faceting parameters by encoding thefacet terms at index time.

在索引时使用基本Solr faceting parameters对facet terms进行编码,是大多数用例下有效基本方法。

Flattened Data “breadcrumbs”

Doc#1: NonFic > Law

Doc#2: NonFic > Sci

Doc#3: NonFic > Hist, NonFic > Sci > Phys

In this example, we have documents associated with multiple categories,like Doc#3. We also have documents that are mapped to internal nodes, likeDoc#2.

在这个例子中,我们的doc与多重分类都有关系,如Doc#3。我们也有doc被映射到了内部节点,如Doc#2

You must perform some index time processing on this flattened data inorder to create the tokens needed for a facet.prefix approach. When we indexthe data we create specially formatted terms that encode the depth informationfor each node that appears as part of the path, and include the hierarchy separatedby a common separator (“depth/first level term/second level term/etc”). We alsoadd additional terms for every ancestors in the original data.

必须花一些索引时间处理flattened数据,以创建facet.prefix方法需要的令牌。当我们索引数据时,我们为路径每一部分节点编码深度信息,创建特殊格式term,并包括被通用分隔符隔开的层次结构(“depth/first levelterm/second level term/etc”) 。我们也为每一个原始数据中的祖先添加了附加的term。

Indexed Terms

Doc#1: 0/NonFic, 1/NonFic/Law

Doc#2: 0/NonFic, 1/NonFic/Sci

Doc#3: 0/NonFic, 1/NonFic/Hist,

            0/NonFic, 1/NonFic/Sci, 2/NonFic/Sci/Phys

Initial Query

With this type of index data, we can then go on and query this to get adrill-down. Initially, we can say we want to facet on the categoryfield with thefacet.prefix “1/NonFic”: things that arechildren ofNonFic at a depth of 1.

说完索引数据的类型,我们可以继续深入研究查询。最初,我们说过我们想使用facet.prefix “1/NonFic” facet on分类字段:NocFic的深度为1的子节点。

facet.field = category

facet.prefix = 1/NonFic

facet.mincount = 1

<result numFound=”3” ...

<lst name=”facet_fields”>

  <lstname=”category”>

     <intname=”1/NonFic/Sci”>2</int>

     <intname=”1/NonFic/Hist”>1</int>

     <intname=”1/NonFic/Law”>1</int>

Drill Down

If we drill down into NonFic/Sci, we just add thefq(filter query) as normal and tweak the facet.prefix from the children1/NonFic to the children of2/NonFic/Sci

如果我们要深入到NonFic/Sci,我们通常只需要添加fq (filter query),并且将facet.prefix从1/NonFic子节点微调到2/NonFic/Sci子节点。

fq = {!raw f=category}1/NonFic/Sci

facet.field = category

facet.prefix = 2/NonFic/Sci

facet.mincount = 1

<result numFound=”2” ...

<lst name=”facet_fields”>

  <lstname=”category”>

     <intname=”2/NonFic/Sci/Phys”>1</int>

We’ve used the depth prefix that lets us look one level deep, but bytweaking the encoding, alternative user experiences can be created.

我们使用了深度前缀,让我们看清了层深,但是我们可以微调编码,建立可供选择的用户体验。

PathHierarchyTokenizerFactory

Solr3.1

The solr.PathHierarchyTokenizerFactory is designed to output file path hierarchies as synonyms,but can also be used in other simple hierarchies.

solr.PathHierarchyTokenizerFactory被设计来输出文件路径层次结构的同义词,但是也可以用在简单的层次结构

Flattened Data

Doc #1: /usr/local/apache

Doc #2: /etc/apache2

Doc #3: /etc/apache2/conf.d

Output Tokens

Doc #1: /usr, /usr/local, /usr/local/apache

Doc #2: /etc, /etc/apache2

Doc #3: /etc, /etc/apache2, /etc/apache2/conf.d

Initial Query

facet.field = category

facet.mincount = 1

<result numFound=”3” ...

<lst name=”facet_fields”>

  <lstname=”category”>

     <intname=”/etc”>2</int>

     <intname=”/etc/apache2”>2</int>

     <intname=”/etc/apache2/conf.d”>1</int>

     <intname=”/usr”>1</int>

     <intname=”/usr/local”>1</int>

     <intname=”/usr/local/apache”>1</int>

Unlike the facet.prefix approach, it isn’t as easy to constrain thedepth of the taxonomies, but for small numbers of terms this may be a goodapproach.

facet.prefix方法不一样,它不容易约束分类的层深,但是对于很小的量还是一个好方法。

Pivot Facets

Solr4.0SOLR-792

Pivot facets are query time constructs that allow arbitrary facetresults, but they should be used wisely to avoid performance bottlenecks.

Pivot facet允许任意的facet结果的查询时概念,但是它们应该用的更精确来避免性能上的瓶颈。

You can think of it as "Decision Tree Faceting" which tells youin advance what the "next" set of facet results would be for a fieldif you apply a constraint from the current facet results, e.g. "for facet A, the constraints/counts are X/N,Y/M,” and if you were to constrain A by X, then the constraint counts for Bwould be S/P, T/Q, etc. Another way to think of it is each field is treated asa vector containing the constraint counts for that field, and taking a"cross product" to produce an N-dimensional matrix showing the countsfor each permutation.

你可以认为它像“决策树 Faceting” 预先告诉你,下一个facet结果接将是你从当前facet结果集上申请约束的字段,例如“对于facet A,约束/数量是X/N,Y/M”并且如果你要通过X约束A,则B的约束数量将是S/P,T/Q等等。以另一种方式来想每一个字段被当作一个包含这个字段约束数量的vector来看,并且那“cross product”来产生一个显示每种排列数量的N维矩阵。

This featurecan be easily applied to hierarchical facets insome cases, particularly those where a particular document only appears at onepoint in the taxonomy.

在一些用例中,这个feature可以很用以的被用于分成的facets,特别是当有一个特别的doc只出现分类的一点。

Flattened Data “breadcrumbs”

Doc#1: NonFic > Law

Doc#2: NonFic > Sci

Doc#3: NonFic > Sci > Phys

At index time, we split the data into a separate field for each level ofthe hierarchy.

在索引时,我们将层次结构中每一层数据分隔到独立的字段中。

Indexed Terms

Doc#1: category_level0: NonFic; category_level1: Law

Doc#2: category_level0: NonFic; category_level1: Sci

Doc#3: category_level0: NonFic; category_level1: Sci,category_level2:Phys

When querying Solr, we specify the facet.pivot parameter, which is acomma-separated list of fields to “pivot” on:

当查询Solr时,我们指定facet.pivot参数,这是一个逗号分隔的列表字段:

facet.pivot = category_level0,category_level1,category_level2

<result numFound=”3” ...

<lst name=”facet_pivot”>

  <arrname=”category_level0,category_level1,category_level2”>

    <lst>

      <str name=”field”>category_level0</str>

      <strname=”value”>NonFic</str>

      <intname=”count”>3</int>

       <arrname=”pivot”>

        <lst>

            <str name=”field”>category_level1</str>

            <str name=”value”>Law</str>

             <intname=”count”>1</int>

        </lst>

        <lst>

            <str name=”field”>category_level1</str>

            <str name=”value”>Sci</str>

            <int name=”count”>2</int>

            <arr name=”pivot”>

              <lst>

                  <strname=”field”>category_level2</str>

                 <str name=”value”>Phys</str>

                 <int name=”count”>1</int>

              </lst>

             </arr>

         </lst>

       </arr>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
资源包主要包含以下内容: ASP项目源码:每个资源包都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值