Whenever I use quotes in a search I get zero results. If I search normally without quotes it works perfectly.
I.E. if i search for "social" i get zero results. If I search for social (without quotes) it works as expected.
This means that searching for a phrase is impossible.

I've tested with different keywords and phrases and it does not matter if it's used in a title, body, taxonomy etc.

To see the bug in action you can go to: http://new-compass.net/
Try searching for keywords from some of the articles there like "social ecology"

Comments

pwolanin’s picture

Category: bug » support

Why do you think a phrase search should work? dismax doesn't handle phrase searches.

olax’s picture

Three reasons I assumed that phrase search would work:
1. It works in the Drupal 6 version.
2. The "no result"-page still mentions phrased search as a option.
3. Apache Solr Search Integration's own "Did you mean" function still suggests phrased searches.

Is phrase search something that will be possible through the version 7 branch of Apache Solr Search Integration in the future?

pwolanin’s picture

We recently made some changes to handling of quote characters to avoid seeing escaped html entities in the search results. It's possible that's the cause. Can you try with the latest 6.x-1.x-dev version?

pwolanin’s picture

Indeed, look in apachesolr_do_query() I changed that in drupal 7 in the commit below. Looking at the dismax docs, I guess we need to revise this.

The original issue is #528086: html entities are not properly handled on search/display

commit 7934383908f057c44b2b66ed69d545b889c1ddd9
Author: Peter Wolanin <pwolanin@49851.no-reply.drupal.org>
Date:   Sat Jan 29 02:39:53 2011 +0000

    #528086  by pwolanin: Fix for special html entity search and display bugs.

diff --git a/apachesolr.module b/apachesolr.module
index 143aff9..3a2fca0 100644
--- a/apachesolr.module
+++ b/apachesolr.module
@@ -1830,7 +1830,7 @@ function apachesolr_do_query($caller, DrupalSolrQueryInterface $current_query, $
   }
   // We must run htmlspecialchars() here since converted entities are in the index.
   // and thus bare entities &, > or < won't match.
-  $response = $query->search(htmlspecialchars($keys, ENT_NOQUOTES, 'UTF-8'));
+  $response = $query->search(htmlspecialchars($keys, ENT_QUOTES, 'UTF-8'));
   // The response is cached so that it is accessible to the blocks and anything
   // else that needs it beyond the initial search.
   apachesolr_static_response_cache($response, $caller);
@@ -2066,7 +2066,7 @@ function apachesolr_clean_text($text) {
   // Add spaces before stripping tags to avoid running words together.
   $text = filter_xss(str_replace(array('<', '>'), array(' <', '> '), $text), array());
   // Decode entities and then make safe any < or > characters.
-  return htmlspecialchars(html_entity_decode($text, ENT_NOQUOTES, 'UTF-8'), ENT_NOQUOTES, 'UTF-8');
+  return htmlspecialchars(html_entity_decode($text, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8');
 }
 
 /**
pwolanin’s picture

Let's consider the issue there, and close this as a dup.

pwolanin’s picture

Status: Active » Fixed
olax’s picture

This problem occurs in the 7-version of the module, not in 6.

pwolanin’s picture

Well, it would have occurred in 6.x HEAD before the fix in http://drupal.org/node/528086 - did you try it?

Status: Fixed » Closed (fixed)

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

mac_weber’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta5
Category: support » bug
Status: Closed (fixed) » Active

I'm using 7.x-1.0-beta5 and I'm still getting no results and no search suggestion for searches using double quotes "like this". If I do the same search using 'single quotes' I get a search suggestion and no results.

pwolanin’s picture

Version: 7.x-1.0-beta5 » 7.x-1.x-dev

The single quotes will not so anything useful - really they will match as an apostrophe basically.

The double quotes work fine for me in the latest 7.x-1.x, so I'd need more detail or need you to test on the latest code to see if the problem is still present.

the beta6 release should be out soon.

mac_weber’s picture

I just switched to 7.x-1.x-dev to test if it is regarding versions.
I uninstalled the old module, I deleted the whole folder.
Then I downloaded again, did not copy the xml files to solr as they look to be the sames as from Beta5, and enabled the module.

On the -dev version I still cannot use double quotes, but instead of just no results it returns an error messge: "The Apache Solr search engine is not available. Please contact your site administrator."

I THINK it may be caused because I'm using multicore solr. My solr server URL was http://localhost:8082/solr/test1 I changed my server to be on http://localhost:8983/solr/test1, but I got the same error. I think in some part of the module apachesolr code it may be looking for something like "http://localhost:8983/solr", without the core on the end, in this case "test1". Again, I'm not sure about it, and it only happens on searches using double quotes.

Another problem I just noticed (probably not related to this bug, but just in case...) is that the search is done based on relevancy. When I click on other kind of sorting methods they work fine. When I try to sort by relevancy again it is not changing how the results are sorted.

pwolanin’s picture

I cannot reproduce the quote issue locally - please provide some more details: Solr version, servlet container, etc.

Created a separate issue for the sort block bug: #1148612: Clicking "Relevancy" has no effect after choosing another sort.

mac_weber’s picture

The problem was on the solr installation.
Do NOT use ubuntu packages to install solr or sorl-jetty. Do NOT download the solr php integration if you are going to install it on Drupal 7(I think it should be on the README). -Thanks pwolanin for helping me to fix it!

As suggested by pwolanin, I did the installation without packages, I did not use tomcat/jetty. I used the start.jar included in solr, making things simpler. I did a multicore installation that looks to be working fine.

Many guides on the internet and drupal.org instructs to install the solr-php library. As it was included in the module from D6 to D7 version I think it should be cited there. Also, from beta5 to beta6 it changed the faceted blocks, now you need to download the Facet API module to make it work (it also needs to be cited on the README).

pwolanin’s picture

start.jar actually runs Jetty which is included with the Solr install (and they use it for testing Solr) - the packages often have wonky configuration.

pwolanin’s picture

Title: Using quotes returns no results » Update README for Drupal 7 changes, package suggestions.
pwolanin’s picture

Title: Update README for Drupal 7 changes, package suggestions. » Using quotes returns no results
Status: Active » Closed (fixed)

Actually we should put this back to closed and have another issue for the README changes.

see: http://drupal.org/node/1150962

plamondonl’s picture

Phrase search not working is indeed a Solr installation problem, not a problem with apachesolr module code nor DisMax handler. I installed Solr from the Ubuntu 10.04 package and I had to do the following in order to make phrase search work:

cd /usr/share/solr/WEB-INF/lib
sudo ln -s ../../../java/lucene-memory.jar

At some point, Solr requires org/apache/lucene/index/memory/MemoryIndex class to be loaded but its .jar wasn't included by default by my package configuration. I've read somewhere that it's phrase highlighting rather than phrase search that needs this class, but I didn't verify.

mac_weber’s picture

@plamondoni as stated in #14, you shoud NOT use the ubuntu packages. This was my mistake.

Follow the new README on the module to install solr, @pwolanin included it on the instructions.

edit: In addition, I did not do anything about memory, nor anything besides what it is written on the new README