views:

37

answers:

3

I need to find the following string: 'c++'

My sql query look like this:

SELECT *
FROM shop_product
WHERE
   MATCH(shop_product.name, shop_product.product_model, shop_product.keywords, shop_product.part_number, shop_product.upc, shop_product.brand_name)
   AGAINST ('c++' IN BOOLEAN MODE))
GROUP BY `product_id`
LIMIT 0, 25

This script does not return any results even if there exists records containing that word. How to solve this?

Thanks.

A: 

"+" isn't a "word" character. Probably you have to use LIKE or REGEXP.

Naktibalda
Is there any escape character for MATCH AGAINST?
Emanuel
A: 

Someone else with the exact same problem here (even down to searching for "C++"!).

It looks like you would need to write your own full text plugin to get it to index C++ as a word.

I've no idea how involved a task that is. Maybe some alternative approaches in this question will help (replace + with _plus before storing the data or use a third party product).

Martin Smith
A: 

You could search without BOOLEAN MODE:

SELECT *
FROM shop_product
WHERE
   MATCH(shop_product.name, shop_product.product_model, shop_product.keywords, shop_product.part_number, shop_product.upc, shop_product.brand_name)
   AGAINST ('c++'))
GROUP BY `product_id`
LIMIT 0, 25

I think the + is just for boolean mode a special character.

JochenJung
@Jochen so far as I understood it it the issue is that it does not even index the `+`s. I may be completely wrong though!
Martin Smith