cassiano has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Im trying to make a search engine, but Im with a problem wich I cant solve, also cant find information about it. Im using dbd & dbi to use mysql with perl. I want to find for exemple: "until" if the user look for "til" or "windows" if the user look for "dows" Im trying to make it using index so I cant use the %% :( . Some of you know a solution for my problem?

Replies are listed 'Best First'.
Re: Search engine help
by Your Mother (Archbishop) on Nov 06, 2004 at 05:58 UTC

    If I understand you correctly you want to index everything so you don't have to do LIKE matches. I think this is both unrealistic and defeats the utility of searching.

    Eg, a casual grep of my dict file gives 1,001 matches for "til" and 7 for "dows" none of which is "windows." (no plurals in the dict.) So searches are going to return tens, hundreds, or thousands (depending on your document base) of meaningless results with this approach.

    Many people do indexes with stemming with things like Lingua::Stem::En and I've seen Text::DoubleMetaphone used to great effect to aid foreign users in finding the English terms and names that natives can barely spell. Both these techniques will blow up DB indexes a lot but still within reason.

    What you seem to be talking about would require indexing everything in every composite element. So something like windows is split into indices: w, wi, win, wind, windo, window, windows, i, in, ind, indo... etc, at some length. Even a partial approach like that (on syllables or something) would probably be huge and not very helpful for searching. Sidenote: I actually wish search engines would never even stem; it clouds result sets more than it helps.

    You can also do LIKE searches on 'partial-string%' with better speed and efficiency than '%partial-string%' if that's something you really need to do. Don't forget to force the user to enter in at least X letters too. There is no point whatsoever in searching for "e" for example and less than 4 characters is not likely to be meaningful in normal text.

Re: Search engine help
by simonm (Vicar) on Nov 06, 2004 at 05:54 UTC
    Sorry, but no -- if you're doing substring matching, you typically can't use a SQL DBMS's indexes.