gpt4 book ai didi

solr - Lucene同时使用分类法和DocValues方面

转载 作者:行者123 更新时间:2023-12-02 22:20:24 25 4
gpt4 key购买 nike

有许多基于分类索引和DocValues使用构面的示例。但是我需要将类别(分类法)和范围查询(NumericDocValuesField)一起用作层次结构。
例如DrillSideways:

  DrillSideways ds = new DrillSideways (searcher, config, taxoReader);
DrillSideways.DrillSidewaysResult result = ds.search (q, topScoreDocCollector);

ds.search()的第二个参数是 TopScoreDocCollector

FacetsCollector ds.search()内部创建,因此无法将此收集器传递给 ds.search()。将 MultiCollector.wrap(FacetsCollector,TopScoreDocCollector)传递为 ds.search()中的第二个参数不正确(?)。但是, FacetsCollector 需要构建分类索引中不可用的构面:
 Facets facetsTime = new LongRangeFacetCounts (..., FacetsCollector, ...);
facetsTime.getTopChildren (...);

还列出 结果.facet 包含空值,这是指 DocValues 方面。

也许您有一个有效的示例,如何将 中的分类法 DocValues 方面一起使用DrillSideways

最佳答案

DrillSideways假定您仅使用TaxonomyFacets或SortedSetDocValuesFacets。如果不是这种情况,则可以继承DrillSideways的子类,并覆盖buildFacetsResult方法来构建最终的Facet(如果您愿意)。对于您添加到DrissSideways中的每个暗角,您将获得用于DrillDownQuery的FacetsCollector和两个带有侧面FacetCollectors和暗角的数组。

这是一个例子:

public class MyDrillSideways extends DrillSideways {

public MyDrillSideways(IndexSearcher searcher, FacetsConfig config, TaxonomyReader taxoReader) {
super(searcher, config, taxoReader);
}

@Override
protected Facets buildFacetsResult(FacetsCollector drillDowns, FacetsCollector[] drillSideways, String[] drillSidewaysDims) throws IOException {

String longRangeFacetDim = "mySpecialLongRangeDim";
Facets drillDownFacets = new FastTaxonomyFacetCounts(taxoReader, config, drillDowns);

boolean foundLongRangeInDrillSideways = false;
Map<String, Facets> drillSidewaysFacets = new HashMap<>();
if (drillSideways != null) {
for (int i = 0; i < drillSideways.length; i++) {
String sidewaysDim = drillSidewaysDims[i];
FacetsCollector drillSideway = drillSideways[i];

Facets sidewaysFacets;
if (sidewaysDim.equals(longRangeFacetDim)) {
foundLongRangeInDrillSideways = true;
sidewaysFacets = new LongRangeFacetCounts(...,drillSideway,...);
} else {
sidewaysFacets = new FastTaxonomyFacetCounts(taxoReader, config, drillSideway);
}
drillSidewaysFacets.put(sidewaysDim, sidewaysFacets);
}
}

if (!foundLongRangeInDrillSideways) {
Facets facetsTime = new LongRangeFacetCounts(..., FacetsCollector, ...);
drillSidewaysFacets.put(longRangeFacetDim, facetsTime);
}

return new MultiFacets(drillSidewaysFacets, drillDownFacets);
}
}

关于solr - Lucene同时使用分类法和DocValues方面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29356341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com