like views_fastsearch
Thanks!!!

Comments

tian’s picture

I'd be interested too!

drupalninja99’s picture

ditto

awolfey’s picture

I'm not doing any more work on the 5.x version of fuzzysearch, but I am happy to work with patches or backports from the 6.x version.

But.... if you look at the views fast search project page:

"This module was the proof of concept of a solution using alternative search SQL that made it into 6.x core. The 6.x implementation is different (better) than this one, but both provide similar speed enhancements. The primary difference is that the 6.x implementation offers better query term support."

So what you are asking for is already in the core search (without the fuzzy part).

awolfey’s picture

Status: Active » Closed (fixed)
weseze’s picture

Version: 5.x-1.2 » 6.x-1.x-dev
Priority: Normal » Minor
Status: Closed (fixed) » Active

A views filter for the fuzzy search query would be really cool to have. So I'll reopen this issue :)

awolfey’s picture

Yes, it's on my list of things to get to eventually. Of course, patches are always welcome!

system32_error’s picture

I know this feature request is a bit old, but if anybody is wondering how to combine fuzzysearch with the views module, here is the solution.

I had no time to create a clean integration, so I used a dirty hack. First of all, you need the views module and the views php filter module.
Create a view and activeate the php filter. Use the "filter to these IDs" option and the "Node ID list" Handler.

After that you have to modify the fuzzysearch module. My version number is 1.5, so in line 1173 of the fuzzysearch.module file you see the output of the results.

delete, or comment this:

$output .= '<div class="search-results">';
  foreach ($results as $result) {
    $i++;
    $odd = $i%2 ? 'odd' : 'even';
    $output .= '<div class="fuzzysearch-result '. $odd .'">';
    $output .= theme('fuzzysearch_result', $result);
    if (variable_get('fuzzysearch_debug_score', FALSE)) {
      $output .= '<p>'. t('Completeness: ') . number_format($result->completeness) . t(' Score: ') . number_format($result->score) .'</p>';
    }
    $output .= '</div>';
  }
  $output .= '</div></div>';

You can get all node id's with this snippet:

foreach( $results as $result ){
  
	$nidz = $result->nid.", ".$nidz;
}

so $nidz looks like " 3, 40, 29 ".

We can now invoke the created view with this snippet:

	$my_content_view = views_get_view('Fuzzysearchview');

	$my_content_view->display["default"]->display_options["filters"]["nid_php"]["value"] = $nidz;

	$display = 'default';
	$my_content_view->build($display);
	$content = $my_content_view->execute_display($display);
	$output .= $content;

Where Fuzzysearchview is out view name.

$my_content_view->display["default"]->display_options["filters"]["nid_php"]["value"] = $nidz; This line tells the view to filter by the search output.

I know this is a dirty hack and one can do this better, but as I allready said, I had no more time....

awolfey’s picture

Priority: Minor » Normal

It would be slightly less hacky to do it like this:

1. Split off the fuzzysearch_process() function into more manageable functions so it would be possible to get an array of nids.
2. In the phpfilter call whatever function gets the array and implode the return array into the string.
3. Or create a views filter handler to take care of #2.

Once I get a stable release for D7 I'll take a look at this again.

anrikun’s picture

Subscribing:
Views provides a filter when the core Search module is enabled.
Fuzzy Search should provide one too.

watman’s picture

@system32_error:
Needed to get an n-gram search working with Views and couldn't go with Solr. This was an easy solution. Quick and dirty, but hey, it works. Thanks.

anybody’s picture

The views integration is a really important point! Is there any work in progress regarding this?

Thank you for your great work! Subscribing.

george.plescan’s picture

I have managed to add a Fuzzy Search functionality to views just by activating the module and using it's index.

In my case I needed to do a search on multiple fields so I added a computed field which concatenates all the data and in views I use that computed field for search. It works also if you use only one field.

It works fine for me but I think I have a PHP error related to this : http://drupal.org/node/1344620.

This was a lucky discovery maybe it will help people interested in fuzzy views search.

memoday’s picture

Hi George,

Can you please explain how you integrated/added the index to Views. What steps did you follow?

Thanks

george.plescan’s picture

You just need to install FuzzySearch normally. You should disable the core Search before as it may create conflicts.

I don't have any specific settings for the FuzzySearch.

So in steps:

1. disable the core Search
2. install FuzzySearch normally
3. add text field for search in the views filter and expose it

That's about it. I am not an expert in FuzzySearch and why it is working like this. Maybe someone else can explain it.

memoday’s picture

Thanks George! I have done as you described, but I am doubtful. In the instructions, it says:

"For Views, make a new view using the default fuzzyseach index, add a page display and configure as desired"

How can we make a new view using the default fuzzysearch index? Is there a way to tell Views to use a particular index? I do not know where this in Views is. Any idea?

awolfey’s picture

memoday, you are reading the D7 instructions.

memoday’s picture

Oh, I am sorry, awolfey. Do you want me to create a new issue for D7? Any setp-by-step guide on how to make it work with Views in D7?

george.plescan’s picture

The steps are the same for both 6 and 7 I think. My instructions are actually based on 7, just now I saw that this issue is for 6.

Anonymous’s picture

Just to note: I don't think what george.plescan is describing actually is using the Fuzzy Search module. It's just using a plain old Views filter with the "contains" operator. Whether you have core search disabled or Fuzzy Search installed is irrelevant; Views will do this all by itself with any field or filter combining module.

I would love to see a Views filter that could talk to Fuzzy Search, which would be a lot faster (query wise) and easier (as it would search all content and fields at once).

mbelos’s picture

Hey guys, I tried to create a View as well and couldn't see the "Default fuzzysearch index" option as explained in the installation instructions until I installed the "Search views" module (which comes with Search API). Hope that helps!

mbelos’s picture

...I spoke to soon, I added a Filter of "Search: Fulltext search" and no query is being run against the database. Can anyone provide step by step instructions for Drupal 7 on how to set up a View?

mbelos’s picture

Ok I have it working I believe. I worked out that my nodes weren't being indexed, so I followed the instructions here: http://drupal.org/node/1346846#comment-5921968

Once the fields were saved and I re-indexed my content (/admin/config/search/search_api/index/default_fuzzysearch_index/status), I created a new View (with the "Show" option set to "Default fuzzysearch index"), added the "Search: Fulltext search" filter criteria (exposed to visitors), "Search: Relevance (desc)" sort criteria and saved.

To test it, I did this:

  • Searched for "lorem", found results
  • Searched for "nullam", found results
  • Searched for "nulam" (notice the missing "L" in the middle), found the same results [although they were sorted slightly differently]

Just a note:

  • To add filters (such as Content type), you must add them to the search index here: /admin/config/search/search_api/index/default_fuzzysearch_index/fields
  • Don't forget to re-index your content (/admin/config/search/search_api/index/default_fuzzysearch_index/status)
  • I found that "Status" of the node didn't filter correctly, so I left it out and everything seemed to work ok from there (not a massive issue on the site I'm working on at the moment)
  • Pagination through the View doesn't seem to work at the moment, not sure why at this stage. If I change the View to display 5 per page, I only get 5 results. If I change the View so it displays all content, it only displays 11 (which is correct for my test case I believe). EDIT: This is probably related - http://drupal.org/node/1441630
memoday’s picture

Thanks mbelos for sharing your solution. Just to confirm, you are using Drupal 7, right? Is this solution for Drupal 7 or Drupal 6?

mbelos’s picture

Yep I'm using Drupal 7.

smptebars1’s picture

Priority: Normal » Major

This integration is almost a must.....
My fuzzy search page just returns the title of several items matching the search. It needs to have the image_cache photo with it.
Customers are complaining that it is hard for them to find what they are looking for, images would make it easier, also maybe integrating with facets search would be nice as well.
Please help us D6 users out on how we can get the results page to look better.

summit’s picture

#22 was a good read me, also for D7! But I can't filter my view on nodetype. Whatever I do there is no result anymore!
Can I set this issue to D7?
Greetings, Martijn

jbergeron’s picture

This is something that I would love to see as well. Seems like a views filter which can be exposed would be the best and cleanest solution.