String field values are treated as is in Solr, without any processing. Unfortunately, this module uses trim() for values when search query is constructing. This means if a string field containing " value" (with leading space) is indexed, it can't be found using filters from this module.

I suggest to check field type before trimming the value to search.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

maximpodorov’s picture

Status: Active » Needs review
FileSize
587 bytes
drunken monkey’s picture

Huh, you're right. Actually, I'm not sure why we would ever want to trim a value there? If a value with a leading/trailing space is coming in, there's gotta be a reason for that. Also, for fulltext fields it won't matter anyways, and I think numeric values would probably get trimmed automatically.
So, actually I'd say we can just remove this line? Patch attached.

In any case, thanks a lot for reporting and providing a patch!

cristiroma’s picture

Status: Needs review » Reviewed & tested by the community

I've just tested this the following way:

1. Attached a text field to Article
2. Added the field to the Index as string & updated the index
3. Created a solr view exposing a filter on the field

Here's the result in Solr console:

Without the patch:

936562 [qtp2135368604-13] INFO  org.apache.solr.core.SolrCore  – [test] webapp=/solr path=/select params={hl.fragsize=0&hl.mergeContiguous=true&hl.simple.pre=[HIGHLIGHT]&json.nl=map&hl.fl=*&wt=json&hl=true&f.content.hl.snippets=3&rows=10&f.content.hl.fragsize=70&fl=*,score&hl.snippets=1&start=0&hl.simple.post=[/HIGHLIGHT]&fq=ss_field_description:"content+with+spaces"&fq=index_id:"default_node_index"&fq=hash:52lzkr} hits=0 status=0 QTime=0 

With patch:

959875 [qtp2135368604-14] INFO  org.apache.solr.core.SolrCore  – [test] webapp=/solr path=/select params={hl.fragsize=0&hl.mergeContiguous=true&hl.simple.pre=[HIGHLIGHT]&json.nl=map&hl.fl=*&wt=json&hl=true&f.content.hl.snippets=3&rows=10&f.content.hl.fragsize=70&fl=*,score&hl.snippets=1&start=0&hl.simple.post=[/HIGHLIGHT]&fq=ss_field_description:"+content+with+spaces+"&fq=index_id:"default_node_index"&fq=hash:52lzkr} hits=1 status=0 QTime=16

So the content is untrimmed and we have 1 hit coming from Solr

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

OK, great to hear. Thanks for testing!
Committed.
Thanks again also to maximpodorov!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.