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.
Comments
Comment #1
douggreen commentedThank 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).
Comment #2
puregin commentedI'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
Comment #3
douggreen commentedPlease 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!
Comment #4
puregin commentedDoug: 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
Comment #5
douggreen commentedcommitted, Thanks!
Comment #6
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.