in reply to Context search term highlighting - Perl is too slow

Context search term highlighing not a trivial problem solved by simple regular expression matching, especially when trying to highlight phrases.

Here's why: swish-e creates a reverse index. It parses documents, extracts out "words" and creates an index. On a search, swish finds the words or phrases you are searching for, and lists the doucments where they are found.

I won't pretend that I understood everything in your explanation about how SWISH-E builds it's index, or how exactly you currently do highlighting, but I do have a general suggestion for simplifying your highlighting process:

As long as all you are doing is "prettying" up the output, then I don't think it's all that important that your highlighting logic EXACTLY match your indexing logic. Looping over each search $word and doing a s/$word/$beg_hl$word$end_hl/g may result in words being highlighted that didn't accutally contribute to the acctual relevance of the document -- but that isn't neccessarily a bad thing.

If I were in your shoes, I would focus on the fact that you are doing two very different things:

  1. Index documents using a specific criteria for what words are relevant to that document.
  2. Provide brief info for each document in a search list that lets people determine by eye if a document is useful to them.
In the case of that second one, you don't have to be exact -- just helpful.

Replies are listed 'Best First'.
Re: Re: Context search term highlighting - Perl is too slow
by moseley (Acolyte) on Dec 20, 2001 at 04:23 UTC
    You are right. In fact the CGI/mod_perl script that comes with swish-e contains a few "highlighting" modules, so you can select speed vs. accuracy.

    Why I'm spending time on this is that it's actually kind of ugly when the highlight doesn't match up -- especially when searching phrases as words get highlighted that really are not related to the search.

    Just trying to have my cake and eat it too.