Page 1 of 1

Search picking up letters from product names

Posted: Fri Jun 27, 2014 2:05 am
by DesignLocker
Hi.

On my site I am searching the term "Red". I am presented with a number of results such as:

Red Felt Bag
Red Laptop Bag
etc...

But I also get results like:

Credit Card Cover
Credit Card Cover Leather
etc..

This is because the letters 'red' existing inside of the word 'credit'. How can I prevent this and simply search the whole word/term only?

Re: Search picking up letters from product names

Posted: Sun Jun 29, 2014 7:25 pm
by melbagnato
Hi DesignLocker,

You can use REGEXP and the [[:<:]] and [[:>:]] word-boundary markers. For example:

Code: Select all

SELECT * FROM table WHERE keywords REGEXP '[[:<:]]red[[:>:]]'
You'll just need to modify the search function being called to include this expression.

Hope this helps.

- Mel