1

我正在尝试SearchComponent基于FacetComponent. 简而言之,我只需要一个将出现在构面中的相同术语的列表,但是,我需要一个该计数和 docFreq 的自定义函数,而不是只计算该给定查询中包含该术语的文档那个词。

我一直在查看代码,FacetComponent发现它以某种方式使用了该DocValuesFacets.getCount方法,但它有数百行长,检查我可能想要的每种方面结果,但我找不到列表的确切位置检索用于构建构面的术语及其计数。

我想做的事情总是单值的,所以我真的只需要一些非常简单的东西,比如:

private NamedList<Double> myCustomFacet(DocSet docs, String fieldName) {
    NamedList<Double> results = new NamedList<Double>();
    List<Term> terms = functionThatGetTheListOfTerms(docs, fieldName); //how do I get this?
    for (term: Terms){
        Integer numDocs = searcher.numDocs(new TermQuery(term), docs);
        Integer docFreq = searcher.docFreq(luceneTerm);
        results.add(term, myCustomMetric(numDocs, docFreq);
    }
    return results;
}

那么,给定一个 DocSet 和一个字段名称,我如何检索该 DocSet 的该字段上的可能术语?

4

0 回答 0