[Xapian-discuss] Returning phrases?

Matthew Somerville matthew at mysociety.org
Mon Feb 18 16:08:21 GMT 2008


>> Is it possible to have xapian search returning excerpt containing
>> the word(s) being searched? Just like google search does...

TheyWorkForYou does snippets positioning and highlighting, for both words 
and phrases; I've just been working on the code so that it still works as 
I'd expect with stemming when that gets turned on. It's not at all pretty, 
but the two functions are position_of_first_word() and highlight() in 
searchengine.php , cvstrac at 
https://secure.mysociety.org/cvstrac/dir?d=mysociety/twfy/www/includes/easyparliament

Basically, for stemming purposes, it splits the text into "wordish" things, 
stems each of them and compares against the stemmed query terms. It does 
words/phrases more directly too. And there's a horrible hack because our 
text is HTML encoded, and I wanted to highlight "foo" when it appears as 
"foo—" (it captures "&" for things like P&O though I don't think that 
works at the moment).

ATB,
Matthew



More information about the Xapian-discuss mailing list