# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User jeremy goecks <jeremy.goecks@emory.edu> # Date 1278183199 14400 # Node ID 40bfc0def292da5d1c83ea3c55ee9915b7fdbf74 # Parent 67f5a7f16c59d3e3bb68b62d278e037975f1c1af Improvements to tool search: (a) search tool title, description, and help and (b) set minimum score for searching to remove very poor results. --- a/lib/galaxy/tools/search/__init__.py +++ b/lib/galaxy/tools/search/__init__.py @@ -8,7 +8,7 @@ try: from whoosh.index import Index from whoosh.qparser import QueryParser tool_search_enabled = True - schema = Schema( id = STORED, title = TEXT, help = TEXT ) + schema = Schema( id = STORED, title = TEXT, description = TEXT, help = TEXT ) except ImportError, e: tool_search_enabled = False schema = None @@ -40,7 +40,7 @@ class ToolBoxSearch( object ): else: return a_basestr - writer.add_document( id=id, title=to_unicode(tool.name), help=to_unicode(tool.help) ) + writer.add_document( id=id, title=to_unicode(tool.name), description=to_unicode(tool.description), help=to_unicode(tool.help) ) writer.commit() def search( self, query, return_attribute='id' ): @@ -48,5 +48,8 @@ class ToolBoxSearch( object ): return [] searcher = self.index.searcher() parser = QueryParser( "help", schema = schema ) - results = searcher.search( parser.parse( query ) ) + # Set query to search title, description, and help. + query = "title:query OR description:query OR help:query".replace( "query", query ) + results = searcher.search( parser.parse( query ), minscore=1.5 ) + print results.scores return [ result[ return_attribute ] for result in results ]