I've created a search view based on the fuzzy search server. After a long time playing with it I think i've just about figured out how to make a block that does the searching and a results page using views. Right now when i enter in a term for instance "test" it will now take me to a results page called

/search-results?search_api_views_fulltext=test

Thats when i get the following error:

Recoverable fatal error: Argument 4 passed to FuzzySearchService::createKeysQuery() must be an array, none given, called in /home/sitename/public_html/sites/all/modules/fuzzysearch/includes/service.inc on line 1091 and defined in FuzzySearchService->createKeysQuery() (line 848 of /home/sitename/public_html/sites/all/modules/fuzzysearch/includes/service.inc).

Comments

xbrianx’s picture

Playing with the URL manually if i replace the ?search_api with just a slash "/" the results seem to show.. But I have no idea how to fix this

memoday’s picture

Hi xbrianx,

I am sorry to jump in. Can you please share how you attach a View to the fuzzysearch server/index? I do not know where to find this in Views. Thanks in advance for your help and sorry if I am a bit out of topic here.

xbrianx’s picture

Yeah I cannot find any documentation on how to use fuzzysearch in views its pretty annoying. But what i figured out is that when you create a new view, instead of selecting a node or taxonomy etc.. a new drop down should appear called or whatever you called it. If you select that you will be able to utilize it in views.... I still haven't been able to get the search results to show on a new page though :\

memoday’s picture

Thanks a million for sharing this. I have just found 'Default fuzzysearch index' in the drop-down list. I will give it a try and see if it can fetch results.

memoday’s picture

OK, I managed to create the View using Default Fuzzysearch index, but whenever I go to the Search tab/View, I get this error message:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'percent' in 'order clause'

if I click 'Apply' again, I get the following error:

Error

The website encountered an unexpected error. Please try again later.

messageRecoverable fatal error: Argument 4 passed to FuzzySearchService::createKeysQuery() must be an array, none given, called in /home1/sitename/public_html/aterm/d7/sites/all/modules/fuzzysearch/includes/service.inc on line 1091 and defined in FuzzySearchService->createKeysQuery() (line 848 of /home1/sitename/public_html/aterm/d7/sites/all/modules/fuzzysearch/includes/service.inc).

Any idea?

xbrianx’s picture

To get past that error with the arguments, you need to set up a filter in views or possibly a sort order too.

memoday’s picture

Thanks xbrianx. Yes, this fixed the first error, but still nothing displays when I search and I keep getting the following message once I hit Apply button. Did you manage to fix it?

Error
The website encountered an unexpected error. Please try again later.
Error message
Recoverable fatal error: Argument 4 passed to FuzzySearchService::createKeysQuery() must be an array, none given, called in /home1/public_html/sitename/d7/sites/all/modules/fuzzysearch/includes/service.inc on line 1091 and defined in FuzzySearchService->createKeysQuery() (line 848 of /home1/public_html/sitename/d7/sites/all/modules/fuzzysearch/includes/service.inc).
xbrianx’s picture

No I've never been able to fix this unfortunately and am waiting for some kind person to give a step by step on how to create a functioning fuzzy search box with views.

awolfey’s picture

Unfortunately this views support is not working for several reasons. It's going to take me some time to work it out because of my workload. Any help would be welcome.

Anonymous’s picture

same problem here

quickly’s picture

I have additional filter in views as well as sort criteria... but I am getting this error msg:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') GROUP BY t.word_id, t.item_id HAVING (SUM(t.completeness) >= '35') UNION ALL' at line 1

I get this error only when I give only integers as search terms and the length of integers is less than Ngram length

benzzon’s picture

I've tried to create a searchable view using the "Default fuzzysearch index" with "filter criteria", but when
testing my new view I get the same error as xbrianx.

It seems as the function "createKeysQuery" is being called with the wrong number of arguments, the
variable "$fuzzy" seems to be missing in some calls.

I tried to make changes in the file "service.inc", but my knowledge of PHP is just about "none" so I got stuck
when i realized that the function "createFilterCondition" might need to be extended with the "$fuzzy"-parameter..

Is there some way to fix the problem, or could you recommend some other solution for
creating a "search"-function that can search "within words"?
("SolR" is not an option as my provider cannot offer this service..)

memoday’s picture

Any progress on this? I have just tested it again and again and it doesn't seem to work. I hope awolfey will have a chance to fix this. This is really a great module with great potential.

gabriel.camby’s picture

Hey there,

I had to get partial search within words working for a project of mine. I stumbled on the same problems described in this thread when trying to integrate it to Search API Views.

Here's a patch I did for the latest git commit (works for the latest 7.x-1.x-dev package as well). The code of the module is still fuzzy to me but I tried to modified it properly. I found that some createKeysQuery calls were incorrect. Other lines were producing SQL errors.

You still need to add both processors to the end of the list in the index configuration though.

I hope you'll find it useful; please review it to your heart's content.

gabriel.camby’s picture

I found that some SQL error is generated when there is no ngram; an empty WHERE clause is added.

Here is an updated version of my patch.

memoday’s picture

Thanks g4be for your kind follow-up on this. I will try your patch and let you know. It is for Drupal 7, right? Does it work with Views error-free now? Thanks again in advance for your great contribution.

memoday’s picture

OK, I confirm that g4be patch is working for Drupal 7. Thanks a million for this. We owe you, Gabriel!

The latest patch is working fine, no more errors thrown my way. Right now, I cannot figure out how this option works though in Views "Fuzzy highlighting of misspelled search terms".

The highlighting is not showing up. Any idea?

Thanks a mil again, Gabriel!

memoday’s picture

I believe there is another issue. I don't think the fuzzy search returns all results. I created 2 views; one using fuzzysearch an the other using Search API DB. The search API DB returns more results than FuzzySearch. I do not know why. Any ideas?

The Search API DB works fine, but unfortunately it throws the following error:

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.word' in 'having clause'"

What are the ideal setting for the fuzzysearch index?

manicato’s picture

I applied the patch, but I get this error:
SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)

awolfey’s picture

Status: Active » Needs work

Thanks g4be for the patch. You've eliminated choice to sort by score or completeness, which I don't want to do. I want to have both options whether in views or search api page.

I'll keep working on this.

In the meantime, I've updated the README.txt with views instructions. (And recently fixed a bunch of other bugs.)

summit’s picture

Hi, Is this patch in https://drupal.org/node/1472116#comment-6499598 correct?
I can;t get any results with adding a nodetype filter to the view, no results are shown...
Greetings, Martijn

tfranz’s picture

Issue summary: View changes
StatusFileSize
new6.7 KB

I had the same error "Recoverable fatal error: Argument 4 passed to FuzzySearchService::createKeysQuery()"

Got it working for fuzzysearch 7.x-1.x-dev (October 1, 2013), patched with https://www.drupal.org/node/2011768#comment-9083131

I think(?) the "trick" was to limit the "Search fields" in the filter "Search: Fulltext search" to "Title" and "The main body text".
And setting "Use as: Search Keys" and "Minimum keyword length: 3".

Attached is a file with the settings of my view - hope it will help someone …

(I'm sorry i didn't test my view any further to find the real problem … because i'm happy that it is working: "never change a running system" … ;-)

sudheeshps’s picture

I am also getting same error "Recoverable fatal error: Argument 4 passed to FuzzySearchService::createKeysQuery()"

seems like patches given are outdated and are not working with current dev version.

Attaching the patch which made it work for me :)

sudheeshps’s picture

Assigned: Unassigned » sudheeshps
Status: Needs work » Needs review

I am also getting same error "Recoverable fatal error: Argument 4 passed to FuzzySearchService::createKeysQuery()"

seems like patches given are outdated and are not working with current dev version.

Attaching the patch which made it work for me :)