1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e38653b24ade/ Changeset: e38653b24ade User: martenson Date: 2015-01-29 17:27:45+00:00 Summary: start of paging; require len(search_term)>2; Affected #: 2 files diff -r 18aa57e52605ca18e6f0e4d1fcfcdff53b0664fa -r e38653b24ade2d72db2ad6196f8b85780311671c lib/galaxy/webapps/tool_shed/api/search.py --- a/lib/galaxy/webapps/tool_shed/api/search.py +++ b/lib/galaxy/webapps/tool_shed/api/search.py @@ -27,9 +27,14 @@ raise exceptions.ConfigDoesNotAllowException( 'Searching the TS through the API is turned off for this instance.' ) if not self.app.config.toolshed_whoosh_index_dir: raise exceptions.ConfigDoesNotAllowException( 'There is no directory for the search index specified. Please ontact the administrator.' ) + if len( search_term ) < 3: + raise exceptions.RequestParameterInvalidException( 'The search term has to be at least 3 characters long.' ) + + page = kwd.get( 'page', 1 ) + callback = kwd.get( 'callback', 'callback' ) repo_search = RepoSearch() - results = repo_search.search( trans, search_term ) + results = repo_search.search( trans, search_term, page ) results[ 'hostname' ] = url_for( '/', qualified = True ) - response = '%s(%s);' % ( kwd.get( 'callback' ), json.dumps( results ) ) + response = '%s(%s);' % ( callback, json.dumps( results ) ) return response diff -r 18aa57e52605ca18e6f0e4d1fcfcdff53b0664fa -r e38653b24ade2d72db2ad6196f8b85780311671c lib/galaxy/webapps/tool_shed/search/repo_search.py --- a/lib/galaxy/webapps/tool_shed/search/repo_search.py +++ b/lib/galaxy/webapps/tool_shed/search/repo_search.py @@ -73,7 +73,7 @@ class RepoSearch( object ): - def search( self, trans, search_term, **kwd ): + def search( self, trans, search_term, page, **kwd ): """ Perform the search on the given search_term @@ -98,7 +98,6 @@ 'remote_repository_url_B' : 0.2, 'repo_owner_username' : 0.3 } ) - # log.debug(repo_weighting.__dict__) searcher = index.searcher( weighting = repo_weighting ) parser = MultifieldParser( [ @@ -112,9 +111,8 @@ # user_query = parser.parse( search_term ) user_query = parser.parse( '*' + search_term + '*' ) - hits = searcher.search( user_query, terms = True ) - # hits = searcher.search( user_query ) - # hits = searcher.search_page( user_query, 1, pagelen = 1, terms = True ) + # hits = searcher.search( user_query, terms = True ) + hits = searcher.search_page( user_query, page, pagelen = 10, terms = True ) log.debug( 'searching for: #' + str( search_term ) ) log.debug( 'total hits: ' + str( len( hits ) ) ) log.debug( 'scored hits: ' + str( hits.scored_length() ) ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.