Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用*通配符时Lucene.net Boost不工作_C#_.net_Lucene_Lucene.net - Fatal编程技术网

C# 使用*通配符时Lucene.net Boost不工作

C# 使用*通配符时Lucene.net Boost不工作,c#,.net,lucene,lucene.net,C#,.net,Lucene,Lucene.net,我有两个文档,使用Luke进行调查,我在代码中使用StandardAnalyzer确认它具有相同的行为 用boost1记录一个 stored/uncompressed,indexed,tokenized<Description:Nummer ett> stored/uncompressed,indexed,tokenized<Id:2> stored/uncompressed,indexed,tokenized<Name:Apa> 搜索ap* 无顺序返回,分

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

用boost1记录一个

stored/uncompressed,indexed,tokenized<Description:Nummer ett>
stored/uncompressed,indexed,tokenized<Id:2>
stored/uncompressed,indexed,tokenized<Name:Apa>
搜索ap* 无顺序返回,分数相同

Document 1 Score 1.0000
Document 2 Score 1.0000
Document 1 Score 1.0000
Document 2 Score 1.0000
搜索apa* 无顺序返回,分数相同

Document 1 Score 1.0000
Document 2 Score 1.0000
Document 1 Score 1.0000
Document 2 Score 1.0000
为什么会这样?我想返回一些具有更高boost值的文档,即使我必须使用通配符。这可能吗

为所有酷的程序员干杯

这就是我想做的帮凶

搜索字符串并希望匹配。使用通配符。 搜索“Lu”+“*”


例如,我希望名为Lund的文档比名为Lunt或City为Lund的文档获得更高的评级。这是因为我知道哪些文档最受欢迎。我想得到斯德哥尔摩市的文件,名字是斯德哥尔摩和斯托克霍尔曼,但按我的选择排序。

因为
WildcardQuery
MultiTermQuery
的一个子类,你得到的恒定分数是1

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

t、 getBoost()是查询q as中术语t的搜索时间提升 在查询文本中指定(请参见查询语法),或按照 对setBoost()的应用程序调用。请注意,实际上没有直接的 API,用于在多术语查询中访问一个术语的提升,但是 相反,多术语在查询中表示为多术语查询 对象,因此可以通过 调用子查询getBoost()

一种可能的攻击可能是设置查询解析器的重写方法:

myCustomQueryParser.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE)

这是一个我很难找到的答案,无论是在书中查找还是在搜索。谢谢,知道它是如何工作的,解决这个问题会容易得多。@很高兴知道它帮助了你。它确实有帮助,但可能还没有完全解决,它会解决的。我认为这很简单,因为我的问题是我认为很多人都想要的。为什么SetMultiTermRewriter方法被认为是一种黑客行为?
myCustomQueryParser.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE)