【问题标题】:Solr 8.1.0 - Get terms frequency for partials wordsSolr 8.1.0 - 获取部分词的词频
【发布时间】:2019-06-03 14:12:40
【问题描述】:

我有以下文件:

doc1
    description: "A doggo is a small dog."
doc2
    description: "My dog is small.
doc3
    description: "My cat is lazy."

我使用以下查询搜索我的文档:

description:*dog* OR small

返回文件:doc1doc2

现在我想获取查询中每个单词的总词频。为此,我正在尝试使用 termfreq() 函数。

termfreq(description, *dog*)
termfreq(description, small)

结果将如下所示:

doc1
    description: "A doggo is a small dog."
    termfreq(description,*dog*): 0
    termfreq(description, small): 1
doc2
    description: "My dog is small.
    termfreq(description, *dog*): 0
    termfreq(description, small): 1

或者结果应该是这样的:

doc1
    description: "A doggo is a small dog."
    termfreq(description, *dog*): 2
    termfreq(description, small): 1
doc2
    description: "My dog is small.
    termfreq(description, *dog*): 1
    termfreq(description, small): 1

我的问题:可以在 termfreq 函数中使用通配符吗?

  • 如果yes:怎么办?
  • If no : 有没有办法获得带有部分词的查询的词频?

编辑:

托管模式

<fieldType name="descriptionNGram" class="solr.TextField" omitNorms="false">
    <analyzer>
      <tokenizer class="solr.StandardTokenizerFactory" />
      <filter class="solr.LowerCaseFilterFactory"/>
      <filter class="solr.NGramFilterFactory" minGramSize="2" maxGramSize="30"/>
    </analyzer>
  </fieldType>

<field name="description" stored="true" type="descriptionNGram" multiValued="false" indexed="true"/>

【问题讨论】:

    标签: search solr wildcard


    【解决方案1】:

    如果您可以在没有前缀通配符的情况下生存,则可以将use the TermsComponent 设置为将terms.lower 设置为开始迭代的令牌。

    如果您需要前缀通配符,则必须改为索引 NGrams,这样您就可以得到one token per combination of letters。所以对于 doggo,你会得到带有dooggggo 等的令牌。

    【讨论】:

    • 我需要前缀通配符,所以我不能使用 terms.lower。对于 Ngram,你能提供一个如何使用它的例子吗?我已经使用过滤器 NGramFilterFactory 配置了我的字段,但使用 termfreq 函数的结果仍然相同。
    • 如果您已经配置了 ngramfilter,请将配置添加到您的问题中 - 并确保在这种情况下您只要求 dog 的 termfreq - 而不是 *dog*
    • 根据您的更新,您使用了 EdgeNGramTokenizer - 它只会从 字符串的开头 生成 ngram。您还使用了 description 字段的类型,而不是您要为其检索 termfreqs 的 text 字段。
    • EdgeNGramTokenizer 不会对空格等进行标记。它只会根据您的输入生成不同长度的标记。使用带有 NGramFilterFactory 的常规标记器(标准或空白)来获得您要求的行为。
    • 我已经更新了字段和过滤器,但仍然没有得到好的结果。我还是错过了什么吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-06
    • 2011-12-03
    相关资源
    最近更新 更多