【问题标题】:Getting a word count frequency out of a page field从页面字段中获取字数频率
【发布时间】:2012-01-20 21:25:06
【问题描述】:

SOLR 报告所有文档中术语的术语出现。我在进行查询时遇到问题,该查询返回名为 documentPageId 的特定页面字段中出现的术语。

我不知道如何发出正确的 SOLR 查询,该查询返回一段文本的字数,例如字段的术语“放大器”。由于某种原因,它只会返回。

即使我在段落中不止一次看到该术语,我尝试过的事情也只会返回该术语出现 1 次的计数。

我尝试在“内容”字段上进行分面

http://localhost:8983/solr/select?indent=on&q=&wt=standard&facet=on&facet.field=documentPageId&facet.query=amplifier&facet.sort=lex&facet.missing=on&facet.method=count

<lst name="facet_counts">
<lst name="facet_queries">
<int name="amplifier">21</int>
</lst>
<lst name="facet_fields">
<lst name="documentPageId">
<int name="49667.1">1</int>
<int name="49667.10">1</int>
<int name="49667.11">1</int>
<int name="49667.12">1</int>
<int name="49667.13">1</int>
<int name="49667.14">1</int>
<int name="49667.15">1</int>
<int>0</int>
</lst>
</lst>
<lst name="facet_dates"/>
<lst name="facet_ranges"/>
</lst>
</response>

在 schema.xml 中:

在 solrconfig.xml 中:

   <str name="facet.field">filewrapper</str>
   <str name="facet.field">caseNumber</str>
   <str name="facet.field">pageNumber</str>
   <str name="facet.field">documentId</str>
   <str name="facet.field">contents</str>
   <str name="facet.query">documentId</str>
   <str name="facet.query">caseNumber</str>
   <str name="facet.query">pageNumber</str>
  <str name="facet.field">documentPageId</str>
   <str name="facet.query">contents</str>

提前致谢,

【问题讨论】:

    标签: solr


    【解决方案1】:

    您需要使用 TermVectorsComponent 来获取给定文档的词频。方面不会让您到达那里。

    请在TermVectorCompoment阅读维基。

    tv.tf 选项将根据每个文档返回给定字段的词频。确保您感兴趣的字段启用了 termVectors (termVectors="true")。

    <field name="pageField" type="text" indexed="true" stored="true" termVectors="true" />
    

    注意:启用术语向量会增加索引大小和索引所需的时间。所以要小心这一点,并在之前和之后进行基准测试。

    【讨论】:

    • 太棒了!这运作良好。但是,为了加快查询速度,如何将其限制为文档页面内的特定术语。它正在返回所有术语及其频率计数。
    • 我猜document page 是指 Solr 中的一个字段。现在,如果您检查 Solr TermVectorComponent 的实现,它在内部使用 Lucene 'IndexReader.getTermFreqVector' 并且没有任何有意义的方法可以仅为字段中的一组术语获取 TermVector 信息。但由于计算大部分术语向量的成本是在索引时间内产生的,因此检索速度应该更快,限制的一种方法是只为特定的fielddocument 和可能只​​是tf 获取它,但是这取决于您的应用程序的设计和使用情况。
    • 看起来您必须进行 2 次查询。第一个查询获取每个页面中的词频,第二个查询获取偏移量。看起来你不能两者都做。
    • 词频查询[link]localhost:8080/solr/select/…
    • 词条偏移量查询 [link]localhost:8080/solr/select/… 第二个查询的问题是它给出了它索引的所有词条的偏移量。你不能把它限制在“放大器”这个词上吗?
    猜你喜欢
    • 2016-06-18
    • 1970-01-01
    • 1970-01-01
    • 2011-03-29
    • 1970-01-01
    • 2013-12-07
    • 1970-01-01
    • 2020-06-08
    • 2013-04-21
    相关资源
    最近更新 更多