When comparing searches via views_fastsearch and searches using Drupal core search, there are discrepancies when using terms that have apostrophes and dashes.

For example, searching on "Bill Jo's" or "e-trade" will not yield results in this module, but will show results in core search.

The solution is simple.

      // walk through each of the values
      // building the AND, OR, and exclusion terms
      $values = explode(' ', search_simplify($filter['value']));
      $word_count = 0;
      foreach ($values as $value) {
        if (strlen($value) < variable_get('minimum_word_size', 3)) {
          continue;
        }

The patch above does two things:

- Uses search_simplify() to strip the special characters, and hence the search string will be broken down into words (e.g. e-trade becomes e+trade).

- Skip the terms that are less than the threshold set in Drupal's search.

This patch has been tested at a live site and works well.

CommentFileSizeAuthor
#3 163311.patch824 bytesdouggreen
#2 views_fastsearch.patch919 bytespuregin

Comments

douggreen’s picture

Thank you! Could you please create a real patch file (see http://drupal.org/patch/create) or at least tell give me some context on where you put the above code snipet (line number and a text of a couple of the lines above and below).

puregin’s picture

Version: 5.x-1.1 » 4.7.x-1.x-dev
Status: Active » Reviewed & tested by the community
StatusFileSize
new919 bytes

I've verified the issue (embedded hyphens and quotes, also 'short' words in search terms cause views_fastsearch to fail where core search succeeds) and verified that the patch supplied by Khaled works.

I'm attaching a patch format file, as requested.

This should be ready to apply.

Djun

douggreen’s picture

Version: 4.7.x-1.x-dev » 5.x-2.x-dev
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new824 bytes

Please only submit patches for the 5.x-2.x-dev version. I've attached what may be the appropriate patch for the current 5.x-2.x-dev version, but would like someone to test and verify it before I commit it. Thanks!

puregin’s picture

Status: Needs review » Reviewed & tested by the community

Doug: patch applies OK for 5.x-2.x-dev version and fixes the issue. I can search for strings containing hyphens, or embedded quotes, and the expected results are returned. Marking as RTBC.

Thanks! Djun

douggreen’s picture

Status: Reviewed & tested by the community » Fixed

committed, Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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