Browse Source

HUE-3570 [notebook] Specify a default Solr SQL collection handler

Romain Rigaux 9 years ago
parent
commit
26bd10156d

+ 2 - 1
desktop/conf.dist/hue.ini

@@ -655,7 +655,8 @@
     [[[solr]]]
       name = Solr SQL
       interface=solr
-      # options='{"collection": "sql_collection"}'
+      ## Name of the collection handler
+      # options='{"collection": "default"}'
 
     # [[[mysql]]]
     #   name=MySql JDBC

+ 2 - 1
desktop/conf/pseudo-distributed.ini.tmpl

@@ -659,7 +659,8 @@
     [[[solr]]]
       name = Solr SQL
       interface=solr
-      # options='{"collection": "sql_collection"}'
+      ## Name of the collection handler
+      # options='{"collection": "default"}'
 
     # [[[mysql]]]
     #   name=MySql JDBC

+ 7 - 2
desktop/libs/notebook/src/notebook/connectors/solr.py

@@ -50,9 +50,14 @@ class SolrApi(Api):
   @query_error_handler
   def execute(self, notebook, snippet):
     from search.conf import SOLR_URL
-    collection = self.options.get('collection') or snippet.get('database') or 'default'
 
-    response = NativeSolrApi(SOLR_URL.get(), self.user.username).sql(collection, snippet['statement'])
+    api = NativeSolrApi(SOLR_URL.get(), self.user.username)
+
+    collection = self.options.get('collection') or snippet.get('database')
+    if collection == 'default':
+      collection = api.collections2()[0]
+
+    response = api.sql(collection, snippet['statement'])
 
     info = response['result-set']['docs'].pop(-1) # EOF, RESPONSE_TIME