求解某些令牌的模糊搜索问题



Enviornment-java版本"11.0.12";2021-07-20 LTS,solr-8.9.0

我有以下Solr索引的字段声明:

<field name="author" type="text_general" multiValued="false" indexed="true" stored="true"/>

字段类型:

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" multiValued="true">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

我理解";Lucene支持基于Levenstein Distance或Edit Distance算法的模糊搜索。做模糊搜索波浪号~&";,使用"单个单词术语"末尾的符号。

~运算符用于运行模糊搜索。我们需要在每个术语后添加~运算符,还可以指定该距离是可选的,如下所示">

{FIELD_NAME:TERM_1~{Edit_Distance}

我的请求如下。

curl -G http://localhost:8983/solr/fuzzyCore/select --data-urlencode "q=(author:Harol~)"

由于"KeywordTokenizer"将整个输入作为一个令牌,并且我希望每个单词都是可搜索的,所以使用了"StandardTokenizer"。

我对以下输入的请求正在正确运行

curl -G http://localhost:8983/solr/fuzzyCore/select --data-urlencode "q=(author:Harol~)" --data-urlencode "rows=2"
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"author:Harol~",
"rows":"2"}},
"response":{"numFound":939,"start":0,"numFoundExact":true,"docs":[
{
"Field1":"1",
"author":"Haxyol",
"Field2":"jfkdl",            
"_version_":1744603055722070016},
{
"Field1":"24583728576090850",
"author":"Hastol",
"Field2":"dfafi fdhee fddfd",            
"_version_":1744602582382280721}]
}}

但没有为以下输入运行

curl -G http://localhost:8983/solr/fuzzyCore/select --data-urlencode "q=(author:pinter~)" --data-urlencode "rows=2"
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"author:pinter~",
"rows":"2"}},
"response":{"numFound":3780,"start":0,"numFoundExact":true,"docs":[
{
"Field1":"2",
"author":"pinter",
"Field2":"jfdfakdl",            
"_version_":1744603055722070016},
{
"Field1":"2458372850",
"author":"pinter",
"Field2":"afdfih hefdad afdsaf",

"_version_":1744602582382280721}]
}}

虽然solr中有一个作者"piopter"被索引,但它不在上述查询的结果中,这是由验证的运行以下查询。

curl -G http://localhost:8983/solr/fuzzyCore/select --data-urlencode "q=(author:piopter)" --data-urlencode "rows=2"
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"author:piopter",
"rows":"2"}},
"response":{"numFound":892,"start":0,"numFoundExact":true,"docs":[
{
"Field1":"3",
"author":"piopter",
"Field2":"fadfjfdfakdl",            
"_version_":1744603055722070016},
{
"Field1":"24dfda58372850",
"author":"piopter",
"Field2":"fdsfafdfi hefda afddsaf",            
"_version_":1744602582382280721}]
}}

为什么"piopter"不是输入">pinter~"的结果,而"Haxyol"是"Harol~"的结论。观察到,Harol~和pinter~分别有9393780的reocrds。solr中存在的索引文档总数为1.6Million记录。

所以我试着发布你需要的一切来理解我的问题。有什么想法吗?solrconfig.xml中有任何需要配置的参数,如threshold、maxResult?

我已经删除了solr中所有"piopter"的文档,然后插入"piopter"的记录很少,现在输入的"pinter"正在成功生产输出为"piopter"。为什么它不适用于更多的文档还是索引?

是否可能您更改了架构,但没有重新索引这些文档?

pinterpiopter的编辑距离为2。高编辑距离会导致糟糕的得分,所以pioter将在3780场比赛的最后。如果我们的数据集由160万个文档组成,那么将有许多更好的匹配品。在编辑距离大于1的大型数据集上进行模糊搜索通常会产生大量噪声。

我对进一步调查的建议:

  • 行设置为1000(或更高(,然后查看是否可以在那里找到它
  • 显式搜索品脱~2。也许有人将默认值配置为1
  • 尝试在离目标较近的地方进行模糊搜索,例如pinpter~1

最新更新