【问题标题】:Word frequency in SolrSolr 中的词频
【发布时间】:2023-03-29 13:58:01
【问题描述】:

我正在尝试使用 solr 获取单词的频率。当我提出这个查询时:

localSolr/solr/select?q=someQuery&rows=0&facet=true&facet.field=content&wt=xml

solr 给了我类似的频率;

<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields">
<lst name="content">
<int name="word1">24</int>
<int name="word2">12</int>
<int name="word3">8</int>

但是当我数单词的时候;我发现 word2 的实际计数是 13。Solr 将字段中的相同单词计数为 1。

例如;

字段文本包括; word2 word5 word7 word9 word2。 Solr 不返回 word2 的计数 2,而是返回 1。它为下面两个句子的 word2 的计数返回 1;

word2 word10 word11 word12
word2 word9 word7 word2 word23

所以频率返回错误。我已经检查了方面字段,但没有找到合适的参数。我该如何解决它,以便它在句子中计算相同的单词?

编辑: schema.xml 的相关部分:

<fieldType name="text_tr" class="solr.TextField" positionIncrementGap="100">
    <field name="content" type="text_tr" stored="true" indexed="true" multiValued="true"/>
    <copyField source="content" dest="text"/>
    <field name="text" type="text_tr" stored="false" indexed="true" multiValued="true"/>

【问题讨论】:

    标签: java solr word-frequency


    【解决方案1】:

    如果你正在分面的字段是多值的,那么分面中的每个单词都会得到正确的计数

    我忘了提一件事:Term Vector Component 会带你去你需要的地方

    在查询中,tv.tf 将为您提供每个术语的术语频率,而 tv.fl 告诉 solr 应该在哪些字段上计算频率 p>

    注意这会使您的索引时间比现在慢(又名:您必须尝试一下)

    【讨论】:

    • 感谢您的回答。我已更改字段以使多值参数为 true,但它仍然返回错误的答案。
    • 你能发布你的 schema.xml,我可以给你更多信息吗?
    • 对不起,我不能把所有的 schema.xml,但我编辑并把相关的部分。我希望它有所帮助。
    • 那里的解释很好
    • @Samuele and yns 我知道你问/回答了这个问题已经有一段时间了,但我有类似的问题,我遵循了 TermVectorComponent 中的指导方针,但我不知道在 http 请求中要更改什么在为“文本”字段设置 TermVectorComponent 后显示在 yns 问题中?
    【解决方案2】:

    使用卢克请求处理程序

    http://localhost:8983/solr/admin/luke?fl=YOUR_TEXT_FIELD&amp;numTerms=500

    更多信息:http://wiki.apache.org/solr/LukeRequestHandler

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 2018-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多