Is it possible to enable a non case-sensitive search

for example

'honda' returns results
'Honda' returns 0 results

there must be some way to ignore case in the searchterm ;-)

DT

Comments

davidwhthomas’s picture

Ok, I actually got this working, and partial word search too by changing 1 line in views_fastsearch.module

around line 124

From:

        $and_clause[] = "$tablename.word = '%s'";

To:

        $and_clause[] = "$tablename.word ILIKE '%s%%'"; //case insensitive LIKE match

Note, this is PostgreSQL specific, for MySQL you'd need something like

        $and_clause[] = "LOWER($tablename.word) LIKE LOWER('%s%%')";

I assume the reason it's not like this by default is performance issues for huge DBs?
In any case it works very efficiently and effectively for me.

regards,

DT

douggreen’s picture

Status: Active » Closed (works as designed)

I don't think that the indexes are case-insensitive. So I don't think that changing this in VFS will help. I think you'll need to look at Drupal core search module.

davidwhthomas’s picture

perhaps the case-sensitivity is just for taxonomy terms.

I'm particularly interested in filtering on free tagging vocab terms and needed to implement a case-insensitive wildcard search of free-tagging vocab terms.

In any case, there was definitely a case-sensitivity issue when the keyword is a taxonomy term.

The fix I posted above works in all cases so far.

DT

civicpixel’s picture

This modification seems to be working well for one of our sites as well, thanks David.

davidwhthomas’s picture

Thanks, glad to hear it.

It's working well for me too.

Thanks to the developer(s) for a very useful module.

DT

s.daniel’s picture

In version 5.x-2.x-dev (2007-Aug-11) I find this code at line 137:
$and_clause[] = "$tablename.data like '%%%s%%'";

Does the talk here apply to dev version as well?

krunar’s picture

hello
i have test the patch to 5.x-2.x-dev and 5.x-2.0 but i can not make it work to search part of the word
if anyone can help i would really apprieciate since my customer is getting a little crazy:)

thank you

radhika.w’s picture

thanks thanks a ton!!
this helped me solve a huge problem..

I am using DRUPAL 6.8 and had the problem for searching case sensitive data ...
I wanted the results for the keywords 'HONDA' and 'honda' and 'HonDa' to be the same ...

But for some reasons Drupal doesnt allow the same ... yes its Drupal specifically, cause when i run the same query in mysql, i get the results for different cases to be same ..

So all i did was i changed the query to something like this:

SELECT * FROM $tablename WHERE title LIKE '%%$keyword%%'|| category LIKE '%%$keyword%%' || theidea LIKE '%%$keyword%%'

Yippee! ! ! ...
It works for me .. !!
Thanks a ton again ..
Enjoy,
Radhika

kamleshpatidar’s picture

Hi Radhika,

SELECT * FROM $tablename WHERE title LIKE '%%$keyword%%'|| category  LIKE                      '%%$keyword%%' || theidea LIKE '%%$keyword%%'
                    

where i will have to add this? In Drupal cire search module or in VFS. I have three exposed fields
1. Search: Fast Index 2 & 3 are CCK fields.
I want all search fields should be non case sensitive & they can search partial word like, kamlesh or kam or lesh.

Best,
Kamlesh

radhika.w’s picture

hi kamlesh,

m sorry wont be very helpful if this is entirely realted to CCK, cause I m not into it at all. However, I believe at the same time, that there shouldnt be much difference anyway :)

Well, the code that I had pasted on the forum is used in a custom module that I had built for profile searching...

I have a module that helps me store the data of 1800 people. The search string that I have pasted, searches the field as per qour requirements :)

Like the search strings 'kam' or 'esh' or 'l' or 'Kam' or 'KAm' or 'LESH' and so on.. would all return results containing 'kamlesh' :)

HTH, :)
Radhika

kamleshpatidar’s picture

Hi Radhika,

Thank you for reply. I am using only Core search technique, & that's not work on partial word search. Now i am using Views Fast Search module (search based on Drupal core Search).

Has anybody ever used OR condition in Views Filter? if Yes then please guide me.

Best,
Kamlesh