Aaryn
Aaryn

Reputation: 1643

Solr query with forward slash does not match

Solr 4.9.1 (can't update as this is a Silverstripe plugin). The issue is on the frontend, but the following is straight out of the Solr query panel. I'm rather new to Solr and so far I have been digging into suggestions on Tokenizers and Filters (but can't make sense of those in the context of this issue), and escaping (which doesn't seem to do anything)

Here is my example with debug output:

Field Value in existing doc: Across the world - Fly/Sail

Query (frontend): Fly/Sail

Search results: 0

Debug Output:

"rawquerystring": "Fly/Sail",
"querystring": "Fly/Sail",
"parsedquery": "PhraseQuery(_text:\"fly sail fly sail\")",
"parsedquery_toString": "_text:\"fly sail fly sail\"",
"explain": {},
"QParser": "LuceneQParser"

Most confusing for me looking at this is why the double up in parsed query? Escaping the forward slash with a backslash doesn't change anything.

If I search for "Fly Sail", the expected results appear.

Edit: My configuration:

<fields>
<field name='_documentid' type='string' indexed='true' stored='true' required='true' />
<field name='ID' type='tint' indexed='true' stored='true' required='true' />
<field name='_text' type='htmltext' indexed='true' stored='true' multiValued='true' />
<field name='VivaTour_TourName' type='text' indexed='true' stored='true' multiValued=''/>
<field name='VivaTour_TourDescription' type='htmltext' indexed='true' stored='true' multiValued=''/>

Edit 2: Screenshot of my Analysis page for this search

https://i.sstatic.net/XAYoo.jpg

Upvotes: 1

Views: 558

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8668

Try the below fieldType for your field "VivaTour_TourName".

<fieldType name="text_wd" class="solr.TextField" positionIncrementGap="100">
    <analyzer type="index">
          <!-- Splits words based on whitespace characters --> 
          <tokenizer class="solr.WhitespaceTokenizerFactory"/>
          <!-- splits words at delimiters based on different arguments --> 
          <filter class="solr.WordDelimiterGraphFilterFactory" preserveOriginal="1" catenateWords="1"/>
          <!-- Transforms text to lower case -->   
          <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>

        <analyzer type="query">
          <tokenizer class="solr.WhitespaceTokenizerFactory"/>
          <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
  </fieldType>

Once you modify the schema.xml, please restart the server and re-index the data.

Please refer the screenshots for your reference.

solr analysis screen 1

solr analysis screen 2

Upvotes: 1

Related Questions