Quicksearch - how to optimize and improve results

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
cmscritic
Regular
Posts: 18
Joined: Fri Feb 20, 2009 6:40 pm
Contact:

Quicksearch - how to optimize and improve results

Post by cmscritic »

Is there some kind of logic behind the Quick Search feature that I am able to tweak? I've got it on my site and doing a simple search for something like "drupal" gives me tons of totally irrelevant results with Drupal articles not even showing on the top of the list.

I'm confused as to how it works or how it can be improved before going live.
Mike Johnston
Senior Editor and Founder
CMS Critic
Linux Critic
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Quicksearch - how to optimize and improve results

Post by garvinhicking »

Hi!

Serendipity uses the MySQL Fulltextsearch to search for entries, which sorts relevance by number and order of appearance of the word; I believe the weight of a keyword in the title, the body and the extended body is equally distributed.

The search is an internal core feature that can be found in include/functions_entries.inc.php, function serendipity_searchEntries(). Inside that function the SQL query to use can be changed via a plugin API event hook.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
cmscritic
Regular
Posts: 18
Joined: Fri Feb 20, 2009 6:40 pm
Contact:

Re: Quicksearch - how to optimize and improve results

Post by cmscritic »

Thanks for the reply. Have you noticed any serious issues with search relevance? For instance, doing a search on my site for the term "drupal" displayed 1 entry that had the word drupal in the paragraph and below it was an actual drupal article that had the term in the title twice and the body more than 6 times and clearly was far more relevant.
Mike Johnston
Senior Editor and Founder
CMS Critic
Linux Critic
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Quicksearch - how to optimize and improve results

Post by garvinhicking »

Hi!

Sorry, I made an error with my statement. Actually, mysql allows to sort by relevance, but actually the current code orders search results by date, to display blog entries in a chronological order like archives and usual blog pages.

Now that I think about this, this is not useful in cases like yours, where you need relevance most. It's funny that nobody ever asked for that. I've just committed a patch to our core that allows plugins to take over the default sorting. If you'd be willing to upgrade to a s9y snapshot (which will contain that patch as of tomorrows) I could write up a little event plugin for you to use?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Quicksearch - how to optimize and improve results

Post by Don Chambers »

Garvin - are you saying that you need to write a plugin that will allow changing the default behavior (date order) of search results?
=Don=
cmscritic
Regular
Posts: 18
Joined: Fri Feb 20, 2009 6:40 pm
Contact:

Re: Quicksearch - how to optimize and improve results

Post by cmscritic »

Hey Garvin,

Thanks for the reply. I'd personally prefer to wait for a stable release. The site is live now and i can't afford to run software that's not stable.

Why not make the changes to the core as opposed to allowing for a plugin to change it? Seems to make more sense that it would use relevance anyway.

Mike
Mike Johnston
Senior Editor and Founder
CMS Critic
Linux Critic
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Quicksearch - how to optimize and improve results

Post by garvinhicking »

Hi!

Yeah, I could also implement this to the core. It's just that a plugin has more flexibility to deal with options like these.

I've just committed an option for the core to define sort order by date or relevance. It'll be part of the 1.5 final release.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply