MySQL Forums
Forum List  »  Full-Text Search

Re: left truncation of search_string
Posted by: Brian Moon
Date: December 07, 2005 08:13AM

That is not supported in mysql. Mysql needs the left side of the string to do lookups in the index.

A hack I have been thinking about is to reverse all words in the search text and put them in the table as well. This does require you have a search table that is not the same as the home for the data. (Edit: thinking about it, you could just have a second field in the table that is included in the FullText index) In all my applications, I create a search table that has one TEXT field that holds all information I want to search on. This allows me to add related words, normalize terms (CD-ROM becomes CDROM).

I use PHP, so I would:

$text_to_index.= " ".strrev($text_to_index);

I could then insert that into the search table.

Then, when a user searches for a left side wildcard, I reverse it:

*_string

becomes:

gnirts_*

Its just an idea though. I have not tried it yet. It should work.

Brian Moon
Phorum Dev Team
http://phorum.org/
-----------------------
dealnews.com - How to go broke saving money.
http://dealnews.com/



Edited 1 time(s). Last edit at 12/07/2005 08:14AM by Brian Moon.

Options: ReplyQuote


Subject
Views
Written By
Posted
7189
November 23, 2005 12:53PM
Re: left truncation of search_string
4536
December 07, 2005 08:13AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.