Пример #1
0
    def after_search(self, search_results, search_params):
        '''

        :param search_results: 
        :param search_params: 

        '''
        from ckan.lib.search import PackageSearchQuery

        # Note: This will be deprecated at some point in favour of the
        # Solr 4 spatial sorting capabilities

        if search_params.get(u'extras', {}).get(u'ext_spatial') and \
                toolkit.asbool(
                    toolkit.config.get(u'ckanext.spatial.use_postgis_sorting',
                                       u'False')):
            # Apply the spatial sort
            querier = PackageSearchQuery()
            pkgs = []
            for package_id, spatial_ranking in search_params[u'extras'][
                    u'ext_spatial']:
                # get package from SOLR
                pkg = querier.get_index(package_id)[u'data_dict']
                pkgs.append(json.loads(pkg))
            search_results[u'results'] = pkgs
        return search_results
Пример #2
0
 def after_search(self, search_results, search_params):
     if search_params.get('extras', {}).get('ext_spatial'):
         # Apply the spatial sort
         querier = PackageSearchQuery()
         pkgs = []
         for package_id, spatial_ranking in search_params['extras']['ext_spatial']:
             # get package from SOLR
             pkg = querier.get_index(package_id)['data_dict']
             pkgs.append(json.loads(pkg))
         search_results['results'] = pkgs
     return search_results
Пример #3
0
    def after_search(self, search_results, search_params):

        # Note: This will be deprecated at some point in favour of the
        # Solr 4 spatial sorting capabilities

        if search_params.get('extras', {}).get('ext_spatial') and \
           p.toolkit.asbool(config.get('ckanext.spatial.use_postgis_sorting', 'False')):
            # Apply the spatial sort
            querier = PackageSearchQuery()
            pkgs = []
            for package_id, spatial_ranking in search_params['extras']['ext_spatial']:
                # get package from SOLR
                pkg = querier.get_index(package_id)['data_dict']
                pkgs.append(json.loads(pkg))
            search_results['results'] = pkgs
        return search_results
Пример #4
0
 def after_search(self, search_results, search_params):
     if search_params.get('extras', {}).get('ext_spatial'):
         # Apply the spatial sort
         querier = PackageSearchQuery()
         pkgs = []
         for package_id, spatial_ranking in search_params['extras']['ext_spatial']:
             # get package from SOLR
             try:
                 pkg = querier.get_index(package_id)['data_dict']
                 pkgs.append(json.loads(pkg))
             except SearchError:
                 # if this dataset is not in the index, then the error goes
                 # in the log to attract attention of sysadmins, but we
                 # still want to try and return the other results, as we
                 # would for a normal CKAN text search.
                 pass
         search_results['results'] = pkgs
     return search_results