Prechádzať zdrojové kódy

HUE-5304 [search] Move list of collections to use the new API

Romain Rigaux 8 rokov pred
rodič
commit
adfd5066af

+ 3 - 2
apps/search/src/search/dashboard_api.py

@@ -20,9 +20,9 @@ import logging
 from dashboard.dashboard_api import DashboardApi
 from dashboard.models import augment_solr_response
 from libsolr.api import SolrApi
+from indexer.solr_client import SolrClient
 
 from search.conf import SOLR_URL
-from search.controller import SearchController
 
 
 LOG = logging.getLogger(__name__)
@@ -39,7 +39,8 @@ class SearchApi(DashboardApi):
     return augment_solr_response(response, collection, query)
 
   def datasets(self, show_all=False):
-    return SearchController(self.user).get_all_indexes(show_all=show_all)
+    client = SolrClient(user=self.user)
+    return [index['name'] for index in client.get_indexes(include_cores=show_all)]
 
   def fields(self, collection):
     return self.api.fields(collection)

+ 1 - 1
desktop/libs/indexer/src/indexer/solr_api.py

@@ -26,7 +26,7 @@ from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.i18n import smart_unicode
 from libsolr.api import SolrApi
 
-from indexer.solr_client import SolrClient, _get_fields
+from indexer.solr_client import SolrClient
 
 
 LOG = logging.getLogger(__name__)

+ 2 - 3
desktop/libs/indexer/src/indexer/solr_client.py

@@ -27,7 +27,6 @@ from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.i18n import smart_str
 from libsolr.api import SolrApi
 from libsentry.conf import is_enabled
-from libzookeeper.conf import ENSEMBLE
 from libzookeeper.models import ZookeeperClient
 from search.conf import SOLR_URL, SECURITY_ENABLED
 
@@ -82,7 +81,7 @@ class SolrClient(object):
     return IS_SOLR_CLOUD
 
 
-  def get_indexes(self):
+  def get_indexes(self, include_cores=False):
     indexes = []
 
     try:
@@ -100,7 +99,7 @@ class SolrClient(object):
         except Exception:
           LOG.exception('Aliases could not be retrieved')
 
-      if not self.is_solr_cloud_mode():
+      if not self.is_solr_cloud_mode() or include_cores:
         solr_cores = self.api.cores()
         for name in solr_cores:
           indexes.append({'name': name, 'type': 'core', 'collections': []})