Solr fuzzy search problem for some tokens

Viewed 11

Enviornment- java version "11.0.12" 2021-07-20 LTS, solr-8.9.0

I have the following field declaration for my Solr index:

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

Field type:

 <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>

I understand that "Lucene supports fuzzy searches based on the Levenshtein Distance, or Edit Distance algorithm. To do a fuzzy search the tilde, "~", symbol at the end of a Single word Term is used.

~ operator is used to run fuzzy searches. We need to add ~ operator after every single term and can also specify distance which is optional after that as below."

{FIELD_NAME:TERM_1~{Edit_Distance}

My request looks like below.

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

Since 'KeywordTokenizer' keeps the whole input as a single token and I want each word to be searchable, so 'StandardTokenizer' is used.

My request is running correctly for following input

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",
        "Field3":"15-1-1992 00:00:00",
        "Field4":"test.txt",
        "Field5":"PER",
        "Field6":"DXLY",
        "Field7":"RSJKIJLM",
        "_version_":1744603055722070016},
      {
        "Field1":"24583728576090850",
        "author":"Hastol",
        "Field2":"Saikh Ahemmed Sabir",
        "Field3":"1986-06-25T00:00:00.000",
        "Field4":"D3fdf10212549",
        "Field4":"fjkfj",
        "Field5":"jfkjdakf",
        "Field6":"fdfadsf",
        "_version_":1744602582382280721}]
  }}

but not running for following input

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",
        "Field3":"15-1-1992 00:00:00",
        "Field4":"test1.txt",
        "Field5":"PfdER",
        "Field6":"DXfdfLY",
        "Field7":"dfadRSJKIJLM",
        "_version_":1744603055722070016},
      {
        "Field1":"2458372850",
        "author":"pinter",
        "Field2":"Safdfikh Ahefdammed Safdsafbir",
        "Field3":"1956-06-25T00:00:00.000",
        "Field4":"D3dfafdf10212549",
        "Field4":"fdffjkfj",
        "Field5":"sffjfkjdakf",
        "Field6":"fdfa",
        "_version_":1744602582382280721}]
  }}

Although there is one author 'piopter' indexed in solr,but it was not in the result of above query, This was verified by running following query.

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:pinter~",
      "rows":"2"}},
  "response":{"numFound":892,"start":0,"numFoundExact":true,"docs":[
      {
        "Field1":"2",
        "author":"piopter",
        "Field2":"fadfjfdfakdl",
        "Field3":"16-1-1992 00:00:00",
        "Field4":"test2.txt",
        "Field5":"fdadPfdER",
        "Field6":"fadfDXfdfLY",
        "Field7":"dfdffadRSJKIJLM",
        "_version_":1744603055722070016},
      {
        "Field1":"24dfda58372850",
        "author":"piopter",
        "Field2":"fdsfSafdfikh Ahefdammed Safdsafbir",
        "Field3":"1946-06-25T00:00:00.000",
        "Field4":"fadfD3dfafdf10212549",
        "Field4":"dfdfdffjkfj",
        "Field5":"dffsffjfkjdakf",
        "Field6":"dfafdfa",
        "_version_":1744602582382280721}]
  }}

why 'piopter' is not result for input 'pinter~' but 'Haxyol' is result of 'Harol~'. Observation is, there are 939 reocrds for Harol~ and 3780 reords for pinter~. Total index document present in solr are 1.6 milion records.

so I tried to post everything you need to understand my problem. Any ideas? Any parameters need to configure in solrconfig.xml like threshold, maxResult ?

0 Answers
Related