I have the same issue as was posted here, an old D6 issue. My requirement is also that if we search for a phrase (within quotation marks) we need to have only the exact matches in the results.

My users have noticed that if you search on a phrase like "cute kittens" then yes, you get exact matches at the top of the result set. But there are non-exact matches in that result set too. If there is also a sort facet for date and the users want the most recent "cute kittens" they can't get them, because the most recent "cute" comes up first, followed by the most recent "kittens" and "cute kittens" are all the way down at the bottom. My poor users can't get their most recent cute kittens!!!

In order for the facets to work along with the search results, exact phrase searches need to *only* return exact phrase results. Is there an easy on/off setting to make this work? Or is this a bug in the way solr works?

Comments

jenlampton created an issue. See original summary.

jenlampton’s picture

Issue summary: View changes
jenlampton’s picture

jgrubb’s picture

Hi Jen, do you know what version of Solr this site is running? I just ran a test on 5.2.1 with two pieces of content

- "Test thing 1"
- "Test item 1"

And using the term "test", both items come back, but using "test thing" only brings back the expected single result.

I'll look into the date facet thing as well.

jenlampton’s picture

Thanks @jgrubb,

I'm using the 7.x-1.8 version of the Apache Solr module, and Acquia hosted Solr. I'm not sure how to tell which version of Solr Acquia is using, but on the Apache Solr Search Settings page it says the schema version is drupal-4.3-solr-3.x. Does that mean the Solr version is 3.x? If so it seems that they are very far behind!

Update: their documentation says this is running Solr 3.5.

jgrubb’s picture

Hey Jenn, I would love to get 3.x running locally to confirm whether or not this is a Solr bug or an issue with our config files in the module, but I am unable. Just so you know, I followed this - https://www.acquia.com/blog/simple-guide-install-apache-solr-3x-drupal-7 - and this as well - https://www.drupal.org/documentation/modules/search/quick-start-solr-3 - and no luck.

I not going to grow this bald patch on my head any more for now, but did want to check in and let you know that I'm attempting to sort this out. I'm reasonably close, I'm just out of time to see it through for now.

John

jenlampton’s picture

Thanks for looking into it @jgrubb, I would love to get this sorted for my client so I'm now also enlarging my own bald patch trying to get solr 3.5 running locally... Will report back if I learn anything.

jgrubb’s picture

Hey! I'm an idiot! I just took a job with Platform.sh and I can spin up a site with Solr 3 in like 3 minutes! Ok, more like 10 to get everything going but I just set up a site with 3.x and got the exact same results as with 5.x. This is disheartening. I'm not super sure what to do at this point. I wonder if it's some config in your setup somewhere that's not filtering out results correctly? Some other module? Thoughts?

jenlampton’s picture

Thanks @jgrubb, I wasn't ever able to get Solr running locally so appreciate you doing the testing for me. The modules I'm using are Apache Solr framework, Apache Solr search and Apachesolr sort. I am using Apache Solr Panels too, but I think all that does is allow me to change the page where the search results appear. I'll start turning stuff off and see if I can track down the source of the issue...

ygerasimov’s picture

@jenlampton the thing you probably would need to do is to limit the phrase slop. You can set the maximum acceptable distance between words. I haven't found the way to set it in drupal yet, but that is the way to go in my opinion.

mausolos’s picture

I'm having the same issue. I'm running solr 5.4.1. When I search for "cell phones" (including the quotes) using apachesolr_autocomplete module, it indicates 15 results. When I hit enter, I get 9448 results. When I go directly to the backend webservice to SOLR and do the query with quotes, I get 15 results. When I do the same query there without quotes, I get 45 results.

When I dpm() the query/params at the query_prepare and query_alter points, I can see the query is still unchanged. Something appears to be happening then between query_alter and actually sending the query off to solr.

mausolos’s picture

So I don't know if this will help any of you, or if my problem is even the same. Here's what I learned on deeper inspection, however:

First of all, I dumped out my very long raw query string. I added one parameter after another in the SOLR backend webservice (raw query parameters) and observed that everything behaved as expected with quoted queries, UNTIL I added &mm=1 (dismax/minimum should match). This basically caused SOLR to act like I wasn't searching for any specific query at all, and barf up every document in the index. Adjusting it to 2 or higher forced the expected results to return. Weird.

I think I should be able to override this in one of the available hooks (either prepare or alter). It's set to 1 in apachesolr_search.module in the apachesolr_search_basic_params() function (mine is heavily patched, so I suspect a patch or line number won't help, but for me it's around line 1132). I'm actually going to have it switch to 2 only if the query includes matching ". It's not perfect, since it probably won't behave the way people expect it will if they do a search for:
repair broken "cell phone"

Here's more info on the mm param:
DisMax Parameters