Advanced Tag Searching in Blosxonomy

Posted Mon, 14 Nov 2005

I revisted my tagsearch implementation this evening and realized I could make it both much simpler and much more powerful. I now support queries with mixed and/or syntax. "and" has higher precedence - so:

http://www.timfanelli.com/tags/python/folksonomy+ruby/blosxonomy

Will return all posts the are tagged ( "python" and "folksonomy" ) or ( "ruby" and "blosxonomy" )

This is accomplished by taking the request string that matches /^\/tags/(.*)/ and splitting it first on +. I then take each element in the resulting array, split on / and find entries that match all the tags. The results are appended together to build the final response.

This is all accomplished in a few simple lines:

m = Regexp::compile( config['tags_path'] + "/(.*)", Regexp::IGNORECASE ).match( pathinfo )
if m
	ortags = m[1].split('+')		
	ortags.each { |andtags| app['entries'] |= fel.getEntriesWithAllTags( andtags.split('/') ) }
end

Where fel is my File Entry Locator. I envision this changing a little bit when I design the SQL Entry Locator, and supporting queries directly in the locator API.

Again, this feature will be released with Blosxonomy 0.6.

Related Books

Mastering JSP Custom Tags and Tag Libraries Search Engine Optimization: Your visual blueprintfor effective Internet marketing (Visual Blueprint) Search Engine Optimization For Dummies (For Dummies (Computer/Tech)) Hip Pocket Guide to HTML 4.01: An A-Z Quick Reference to HTML Tags JSP Tag Libraries

Post a Comment




About

My name is Tim Fanelli, I am a software engineer in Northern NY. I spend most of my time working, and when I can, I try to post interesting things here.

Cigar Dossiers