<tfoot id='JpZY7'></tfoot>
<legend id='JpZY7'><style id='JpZY7'><dir id='JpZY7'><q id='JpZY7'></q></dir></style></legend>
      <bdo id='JpZY7'></bdo><ul id='JpZY7'></ul>

      <small id='JpZY7'></small><noframes id='JpZY7'>

      1. <i id='JpZY7'><tr id='JpZY7'><dt id='JpZY7'><q id='JpZY7'><span id='JpZY7'><b id='JpZY7'><form id='JpZY7'><ins id='JpZY7'></ins><ul id='JpZY7'></ul><sub id='JpZY7'></sub></form><legend id='JpZY7'></legend><bdo id='JpZY7'><pre id='JpZY7'><center id='JpZY7'></center></pre></bdo></b><th id='JpZY7'></th></span></q></dt></tr></i><div id='JpZY7'><tfoot id='JpZY7'></tfoot><dl id='JpZY7'><fieldset id='JpZY7'></fieldset></dl></div>

      2. 如何对 Solr 中的多个字段执行嵌套聚合?

        时间:2023-06-28
        <legend id='4Pzp9'><style id='4Pzp9'><dir id='4Pzp9'><q id='4Pzp9'></q></dir></style></legend>
      3. <small id='4Pzp9'></small><noframes id='4Pzp9'>

            • <bdo id='4Pzp9'></bdo><ul id='4Pzp9'></ul>
                <tbody id='4Pzp9'></tbody>
              <i id='4Pzp9'><tr id='4Pzp9'><dt id='4Pzp9'><q id='4Pzp9'><span id='4Pzp9'><b id='4Pzp9'><form id='4Pzp9'><ins id='4Pzp9'></ins><ul id='4Pzp9'></ul><sub id='4Pzp9'></sub></form><legend id='4Pzp9'></legend><bdo id='4Pzp9'><pre id='4Pzp9'><center id='4Pzp9'></center></pre></bdo></b><th id='4Pzp9'></th></span></q></dt></tr></i><div id='4Pzp9'><tfoot id='4Pzp9'></tfoot><dl id='4Pzp9'><fieldset id='4Pzp9'></fieldset></dl></div>

              • <tfoot id='4Pzp9'></tfoot>
                  本文介绍了如何对 Solr 中的多个字段执行嵌套聚合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试以嵌套方式按多个字段执行搜索结果聚合(计数和总和)分组.

                  I am trying to perform search result aggregation (count and sum) grouping by several fields in a nested fashion.

                  例如,使用本文末尾显示的架构,我希望能够获得按类别"分组并按子类别"进一步分组的大小"总和,并得到类似这个:

                  For example, with the schema shown at the end of this post, I'd like to be able to get the sum of "size" grouped by "category" and sub-grouped further by "subcategory" and get something like this:

                  <category name="X">
                    <subcategory name="X_A">
                      <size sum="..." />
                    </subcategory>
                    <subcategory name="X_B">
                      <size sum="..." />
                    </subcategory>
                  </category>
                  ....
                  

                  我主要关注 Solr 的 Stats 组件,据我所知,它不允许嵌套聚合.

                  I've been looking primarily at Solr's Stats component which, as far as I can see, doesn't allow nested aggregation.

                  如果有人知道使用或不使用 Stats 组件的某种方式来实现这一点,我将不胜感激.

                  I'd appreciate it if anyone knows of some way to implement this, with or without the Stats component.

                  这是目标架构的精简版:

                  Here is a cut-down version of the target schema:

                  <types>
                    <fieldType name="string" class="solr.StrField" />
                    <fieldType name="text" class="solr.TextField">
                      <analyzer><tokenizer class="solr.StandardTokenizerFactory" /></analyzer>
                    </fieldType>
                    <fieldType name="date" class="solr.DateField" />
                    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
                  </types>
                  
                  <fields>
                    <field name="id" type="string" indexed="true" stored="true" />
                    <field name="category" type="text" indexed="true" stored="true" />
                    <field name="subcategory" type="text" indexed="true" stored="true" />
                    <field name="pdate" type="date" indexed="true" stored="true" />
                    <field name="size" type="int" indexed="true" stored="true" />
                  </fields>
                  

                  推荐答案

                  Solr 5.1 中新的 faceting 模块可以做到这一点,它被添加到 https://issues.apache.org/jira/browse/SOLR-7214

                  The new faceting module in Solr 5.1 can do this, it was added in https://issues.apache.org/jira/browse/SOLR-7214

                  以下是如何将 sum(size) 添加到每个构面桶,并按该统计数据降序排序.

                  Here is how you would add sum(size) to every facet bucket, and sort descending by that statistic.

                  json.facet={
                    categories:{terms:{
                      field:category,
                      sort:"total_size desc",  // this will sort the facet buckets by your stat 
                      facet:{
                        total_size:"sum(size)"  // this calculates the stat per bucket
                      }
                    }}
                  }
                  

                  这就是您在子类别中添加子方面的方式:

                  And this is how you would add in the subfacet on subcategory:

                  json.facet={
                    categories:{terms:{
                      field:category,
                      sort:"total_size desc",
                      facet:{
                        total_size:"sum(size)",
                        subcat:{terms:{ // this will facet on the subcategory field for each bucket
                          field:subcategory,
                          facet:{
                           sz:"sum(size)"  // this calculates the sum per sub-cat bucket          
                        }}
                      }
                    }}
                  }
                  

                  因此,以上内容将为您提供类别和子类别级别的总和(大小).新 facet 模块的文档目前位于 http://yonik.com/json-facet-api/

                  So the above will give you the sum(size) at both the category and subcategory levels. Documentation for the new facet module is currently at http://yonik.com/json-facet-api/

                  这篇关于如何对 Solr 中的多个字段执行嵌套聚合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Lucene 4.0 中的词频 下一篇:Solr:如何动态提升有限数量的文档?QueryElevationComponent 是否需要修改?

                  相关文章

                    <i id='08DM1'><tr id='08DM1'><dt id='08DM1'><q id='08DM1'><span id='08DM1'><b id='08DM1'><form id='08DM1'><ins id='08DM1'></ins><ul id='08DM1'></ul><sub id='08DM1'></sub></form><legend id='08DM1'></legend><bdo id='08DM1'><pre id='08DM1'><center id='08DM1'></center></pre></bdo></b><th id='08DM1'></th></span></q></dt></tr></i><div id='08DM1'><tfoot id='08DM1'></tfoot><dl id='08DM1'><fieldset id='08DM1'></fieldset></dl></div>

                    <small id='08DM1'></small><noframes id='08DM1'>

                    <legend id='08DM1'><style id='08DM1'><dir id='08DM1'><q id='08DM1'></q></dir></style></legend>

                    <tfoot id='08DM1'></tfoot>

                      • <bdo id='08DM1'></bdo><ul id='08DM1'></ul>