【发布时间】: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
返回文件:doc1 和 doc2
现在我想获取查询中每个单词的总词频。为此,我正在尝试使用 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"/>
【问题讨论】: