Эх сурвалжийг харах

HUE-5304 [indexer] Use new API to list indexes

Romain Rigaux 8 жил өмнө
parent
commit
bd556c3

+ 4 - 14
desktop/libs/indexer/src/indexer/api.py

@@ -27,8 +27,8 @@ from desktop.lib.exceptions_renderable import PopupException
 from search.models import Collection
 
 from indexer.controller import CollectionManagerController
-from indexer.utils import fields_from_log, field_values_from_separated_file, get_type_from_morphline_type, \
-  get_field_types
+from indexer.solr_client import SolrClient
+from indexer.utils import fields_from_log, field_values_from_separated_file, get_type_from_morphline_type, get_field_types
 
 
 LOG = logging.getLogger(__name__)
@@ -117,21 +117,11 @@ def autocomplete(request):
 
 
 def collections(request):
-  searcher = CollectionManagerController(request.user)
-  solr_collections = searcher.get_collections()
-  massaged_collections = []
-
-  for collection in solr_collections:
-    massaged_collections.append({
-      'name': collection,
-      'isCoreOnly': solr_collections[collection]['isCoreOnly'],
-      'isAlias': solr_collections[collection].get('isAlias', False),
-      'collections': solr_collections[collection].get('collections', []),
-    })
+  client = SolrClient(user=request.user)
 
   response = {
     'status': 0,
-    'collections': massaged_collections
+    'collections': client.get_indexes()
   }
 
   return JsonResponse(response)