solr strdist不会返回1.0的分数
我想检查查询和文档标题之间的Levenstein距离,然后根据它们的strist分数过滤结果 模式是:solr strdist不会返回1.0的分数,solr,levenshtein-distance,Solr,Levenshtein Distance,我想检查查询和文档标题之间的Levenstein距离,然后根据它们的strist分数过滤结果 模式是: <fields> <field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="title" type="text_general" indexed="true" stored="true" required="true"
<fields>
<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="title" type="text_general" indexed="true" stored="true" required="true" />
<field name="_version_" type="long" indexed="true" stored="true" multiValued="false" />
</fields>
因此,当我发送以下查询时:
http://localhost:8983/solr/collection1/query?q=title:iPhone+4S+Battery+Replacement&fl=*,score,lev_dist:strdist("iPhone+4S+Battery+Replacement",title,edit)
我得到:
{
"id":"1",
"title":"iPhone 4S Battery Replacement",
"_version_":1452659974334316549,
"score":6.4907703,
"lev_dist":0.37931037
}
但我希望得到lev_dist=1.0。为什么是0.379?
我做错了什么?根据strdist函数,需要两个字符串来比较它们。它在分析的字段上的工作方式不同
计算两个字符串之间的距离。使用Lucene拼写检查器StringDistance接口,支持该软件包中的所有可用实现,并允许应用程序通过Solr的资源加载功能插入自己的应用程序。strdist获取(string1、string2、距离测量)
试过之后,谁有类似的问题,您需要在模式中添加一个类似于title\u raw
的字段,见下文,然后重新索引
那么你会想要什么
query?q=title:iPhone+4S+Battery+Replacement&fl=*,score,lev_dist:strdist("iPhone 4S Battery Replacement",title_raw,edit)
如您所见,我从要比较的第一个字符串中删除了+
,因为在计算距离时也会考虑它们
query?q=title:iPhone+4S+Battery+Replacement&fl=*,score,lev_dist:strdist("iPhone 4S Battery Replacement",title_raw,edit)