offline
offline

Reputation: 1619

Solr do not find record if query string starts with short word

I am using solr 4, and I have length filter factory in place

<filter class="solr.LengthFilterFactory" min="3" max="99"/>

If my query string starts with the word that has less than 3 characters, solr will not return any results. I was not expecting this to be the problem because I am using LengthFilterFactory. Here are the examples:

title is: "In the close future..."

if I search q:In the close future, solr returns nothing
if I search q:the close future, solr finds the record

title is: "I have some solr problem" same happens as above...

I can not allow for words shorter than 3 characters to be searched, but I was not expecting that if I use word shorter than 3 characters, it would cause solr to fail. Maybe LengthFilterFactory is not the problem here?

Here is my query example:

INFO: [collection1] webapp=/solr-example path=/select params={mm=100%25&json.nl=flat&fl=id&start=0&sort=date_0_i+desc,hour_0_i+desc&fq=type_s:(1+5+6+8+9+10)&fq=site_i:1&fq=terms_txt:I+have+some+solr+problem&fq=date_in_i:[20050101+TO+*]&fq=date_in_i:[*+TO+20171012]&fq=language_is:0&rows=10&bq=&q=I+have+some+solr+problem&tie=0.1&defType=edismax&omitHeader=true&qf=terms_txt&wt=json} hits=0 status=0 QTime=1

Here is my schema bellow. I will show you the field definition for the filed that I am searching from. Anyone have any idea what is wrong here ?

<fieldType name="text_general_example" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-FoldToASCII.txt"/>          
    <charFilter class="solr.HTMLStripCharFilterFactory"/>
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="(^|\s)([^\-\_&amp;\s]+([\-\_&amp;]+[^\-\_&amp;\s]*)+)(?=(\s|$))" replacement="$1MжџљМ$2 $2" />
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="\bMжџљМ([^\s]*?)\b[\-_&amp;]+" replacement="MжџљМ$1" />
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="\bMжџљМ([^\s]*?)\b[\-_&amp;]+" replacement="MжџљМ$1" />
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="\bMжџљМ([^\s]*?)\b[\-_&amp;]+" replacement="MжџљМ$1" />
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="MжџљМ" replacement="" />
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="(\w)&amp;(\w)" replacement="$1and$2" />
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.LengthFilterFactory" min="3" max="99"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="\b[\-_]+\b" replacement="" />
    <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-FoldToASCII.txt"/>
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="(\w)&amp;(\w)" replacement="$1and$2" />
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.LengthFilterFactory" min="3" max="99"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
  </analyzer>
</fieldType>

Upvotes: 0

Views: 475

Answers (1)

Mysterion
Mysterion

Reputation: 9320

The problem with your query is, that if you're searching for

field:I have a problem

than, after parsing you will actually get the following query field:I defaultField:have defaultField:a ..., where default field is usually specified in your solrconfig.xml. You could as well debug these problems by yourself, by using parameter debugQuery

Some of the tokens will be eliminated, and that's the reason why you didn't get proper results. To do a proper query, you need to enclose query with double quotes "

Upvotes: 1

Related Questions