使用*通配符时,Lucene .net Boost无法正常工作

Jus*_*sTh 8 .net c# lucene lucene.net

我有两个文件并使用Luke进行调查,我已在代码中确认它具有相同的行为,使用StandardAnalyzer.

用boost 1记录一个

stored/uncompressed,indexed,tokenized<Description:Nummer ett>
stored/uncompressed,indexed,tokenized<Id:2>
stored/uncompressed,indexed,tokenized<Name:Apa>
Run Code Online (Sandbox Code Playgroud)

文件二与boost 2

stored/uncompressed,indexed,tokenized<Description:Nummer två>
stored/uncompressed,indexed,tokenized<Id:1>
stored/uncompressed,indexed,tokenized<Name:Apa>
Run Code Online (Sandbox Code Playgroud)

在字段中搜索apa名称使用提升并以正确的顺序返回.

Document 2 has Score 1,1891
Document 1 has Score 0.5945
Run Code Online (Sandbox Code Playgroud)

搜索ap*以无顺序和相同分数返回

Document 1 Score 1.0000
Document 2 Score 1.0000
Run Code Online (Sandbox Code Playgroud)

搜索apa*以无顺序和相同分数返回

Document 1 Score 1.0000
Document 2 Score 1.0000
Run Code Online (Sandbox Code Playgroud)

为什么是这样?我想返回一些具有更高提升值的文档,即使我必须使用通配符.这可能吗?

欢呼所有酷酷的编码员!

这就是我想要帮助的.

搜索字符串并希望匹配.使用通配符.搜索"Lu"+"*"

Document
 Name
 City
Run Code Online (Sandbox Code Playgroud)

我希望名称为Lund的Document获得比具有Name Lunt或City为Lund的文档更高的评级.这是因为我会知道哪些文件最受欢迎.我想获得斯德哥尔摩市的文件,并命名斯德哥尔摩和斯托克霍尔曼,但我可以选择订购.

ZeN*_*eNo 10

既然WildcardQueryMultiTermQuery你的子类,你得分为1.

如果你检查定义t.getBoost():

t.getBoost()是查询q中的术语t的搜索时间提升,如查询文本中所指定的(请参阅查询语法),或者由应用程序调用setBoost()设置.请注意,在多项查询中实际上没有用于访问一个术语的增强的直接API,而是在查询中将多个术语表示为多个TermQuery对象,因此可以通过调用查询中的术语来增强查询中的术语.子查询getBoost()

http://lucene.apache.org/core/old_versioned_docs/versions/3_0_1/api/core/org/apache/lucene/search/Similarity.html#formula_termBoost

一个可能的黑客可能是设置查询解析器的重写方法:

myCustomQueryParser.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE)
Run Code Online (Sandbox Code Playgroud)

  • 为什么 SetMultiTermReWriteMethod 被认为是一个黑客? (2认同)