I'm having a weird issue with string grouping, I was wondering if anyone might have suggestions on what to look at.

I'm maintaining a site that has a nodes indexed at HostedApacheSolr. One of the nodes has a title e.g. "A Banana in the Tree eBook" and there are several other nodes which mention "a banana in the tree" in their body text. Searching for different strings return different results sets in an unusual way:

  • "A Banana in the Tree eBook" (with quotes) - returns correct results.
  • "A Banana in the Tree" (with quotes) - returns correct results.
  • "Banana in the Tree" (with quotes) - returns no results.
  • Banana in the Tree (without quotes) - returns correct results.

Anyone have any thoughts on why adding the single word "a" before "banana in the tree" would give correct results, but without the "a" it gives no results at all?

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

Issue summary: View changes
damienmckenna’s picture

damienmckenna’s picture

I'm getting somewhere.

Using Solr Devel I've worked out that the requests's query string is being modified before it's sent to Solr:

  • "A banana in the tree" is changed to: (("banana") OR ("the") OR ("tree"))
  • "banana in the tree" is changed to: "banana the tree"

So it seems like something is stripping out words and completely changing the possible results.

damienmckenna’s picture

Project: Search API Solr » Search API
Component: Miscellaneous » Views integration

Moving this to the main module as I think the problem may stem from the Views integration.

damienmckenna’s picture

Digging through the functionality, the search string is being changed in SearchApiViewsHandlerFilterFulltext::exposed_validate(). It turned out that the string is a) being split up via preg_split(), and b) the view had a minimum length set I wasn't aware of :)

So, this then brings up something - using preg_split() is a little insufficient, at the very least it doesn't retain strings passed in with quotes; the search.module uses an extensive amount of logic to do this, never mind Lucene ;-)

damienmckenna’s picture

In debugging it further I'm seeing differences between the results provided by the hosted Solr service and my local instance, so I'm going to dig into this further.

drunken monkey’s picture

Category: Support request » Bug report
Status: Active » Needs review
StatusFileSize
new840 bytes

Thanks for reporting this problem, and debugging it so thoroughly!
You're right, of course, we can't just remove parts of quoted strings from the keywords.
The attached patch should fix this, please test!

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

Ok, that appears to be helping, it is at least now passing the quoted phrase through to the "q" argument, so thanks for that. We're still not getting the exact results, but I think there are other issues.

  • drunken monkey committed 8afc105 on 7.x-1.x
    Issue #2822145 by drunken monkey: Fixed problem with phrase search in...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear it helped, thanks for reporting back!
Committed.

Status: Fixed » Closed (fixed)

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