Bläddra i källkod

[search] Partial cleanup of indexer

Romain Rigaux 11 år sedan
förälder
incheckning
d6f1692

+ 1 - 1
apps/search/src/search/api.py

@@ -294,7 +294,7 @@ class SolrApi(BaseSolrApi):
           ('path', '/clusterstate.json'),
       )
       response = self._root.get('zookeeper', params=params)
-      return json.loads(response['znode']['data'])
+      return json.loads(response['znode'].get('data', '{}'))
     except RestException, e:
       raise PopupException(e, title=_('Error while accessing Solr'))
 

+ 7 - 5
apps/search/src/search/templates/admin_collections.mako

@@ -27,16 +27,15 @@ ${ commonheader(_('Search'), "search", user, "29px") | n,unicode }
 <link rel="stylesheet" href="/search/static/css/admin.css">
 
 <div class="search-bar" style="height: 30px">
-    <div class="pull-right" style="margin-top: 4px; margin-right: 20px">
-    <a class="btn" href="${ url('search:new_search') }"><i class="fa fa-file-o"></i> ${ _('New dasboard') }</a>
+    <div class="pull-right" style="margin-top: 4px; margin-right: 20px">    
     <button type="button" class="btn importBtn">
       <i class="fa fa-plus-circle"></i> ${ _('Import Index') }
     </button>
     <a class="btn importBtn" href="${ url('indexer:collections') }">
-      <i class="fa fa-plus-circle"></i> ${ _('Indexes') }
+      <i class="fa fa-database"></i> ${ _('Indexes') }
     </a>
     </div>
-  <h4>${_('Dashboards')}</h4>
+  <h4><a href="">${_('Dashboards')}</a></h4>
 </div>
 
 
@@ -45,9 +44,12 @@ ${ commonheader(_('Search'), "search", user, "29px") | n,unicode }
   <%actionbar:render>
     <%def name="search()">
       <input type="text" placeholder="${_('Filter dashboards...')}" class="input-xlarge search-query" id="filterInput" data-bind="visible: collections().length > 0 && !isLoading()">
+      &nbsp;
+      &nbsp;
+      <a class="btn" href="${ url('search:new_search') }" title="${ _('Create a new dashboard') }"><i class="fa fa-plus-circle"></i> ${ _('Dasboard') }</a>      
     </%def>
 
-    <%def name="creation()">
+    <%def name="creation()">    
     </%def>
   </%actionbar:render>
 

+ 8 - 2
apps/search/src/search/templates/no_collections.mako

@@ -17,7 +17,6 @@
 <%!
 from desktop.views import commonheader, commonfooter
 from django.utils.translation import ugettext as _
-import urllib
 %>
 
 <%namespace name="macros" file="macros.mako" />
@@ -45,7 +44,14 @@ ${ commonheader(_('Search'), "search", user, "120px") | n,unicode }
 
       <i class="fa fa-search waiting"></i>
       <h1>${ _('It seems there is nothing to search on ...') }</h1>
-
+      % if user.is_superuser:
+      <h1>
+        ${ _('... First create a search index with ') }
+        <a class="btn importBtn" href="${ url('indexer:collections') }">
+          <i class="fa fa-database"></i> ${ _('Indexer') }
+        </a>      
+      </h1>
+      % endif
     </div>
   </div>
 </div>

+ 1 - 23
apps/search/src/search/templates/search.mako

@@ -297,10 +297,6 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 
 
 <script type="text/html" id="hit-widget">
-  <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
-
-  <!-- /ko -->
-
   <!-- ko if: $root.getFacetFromQuery(id()) -->
   <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
     <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">      
@@ -340,9 +336,6 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 </script>
 
 <script type="text/html" id="facet-widget">
-  <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
-  <!-- /ko -->
-
   <div class="widget-spinner" data-bind="visible: isLoading()">
     <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
     <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
@@ -432,7 +425,7 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
           <a href="javascript: void(0)" class="pull-right" data-bind="click: function(){ $root.collection.template.showFieldList(false) }">
             <i class="fa fa-chevron-left"></i>
           </a>
-          <input type="text" data-bind="value: $root.collection.template.fieldsAttributesFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter fields')}" style="width: 70%; margin-bottom: 10px" />
+          <input type="text" data-bind="clearable: $root.collection.template.fieldsAttributesFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter fields')}" style="width: 70%; margin-bottom: 10px" />
         </div>
         <div style="border-bottom: 1px solid #CCC; padding-bottom: 4px">
           <a href="javascript: void(0)" class="btn btn-mini"
@@ -674,9 +667,6 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 </script>
 
 <script type="text/html" id="histogram-widget">
-  <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
-  <!-- /ko -->
-
   <div class="widget-spinner" data-bind="visible: isLoading()">
     <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
     <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
@@ -706,9 +696,6 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 </script>
 
 <script type="text/html" id="bar-widget">
-  <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
-  <!-- /ko -->
-
   <div class="widget-spinner" data-bind="visible: isLoading()">
     <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
     <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
@@ -745,9 +732,6 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 </script>
 
 <script type="text/html" id="line-widget">
-  <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
-  <!-- /ko -->
-
   <div class="widget-spinner" data-bind="visible: isLoading()">
     <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
     <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
@@ -774,9 +758,6 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 
 
 <script type="text/html" id="pie-widget">
-  <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
-  <!-- /ko -->
-
   <!-- ko if: $root.getFacetFromQuery(id()) -->
   <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
     <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
@@ -843,9 +824,6 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 </script>
 
 <script type="text/html" id="map-widget">
-  <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
-  <!-- /ko -->
-
   <!-- ko if: $root.getFacetFromQuery(id()) -->
   <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
     <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">

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

@@ -789,7 +789,7 @@
 
 
 ###########################################################################
-# Settings to configure Hbase
+# Settings to configure HBase Browser
 ###########################################################################
 
 [hbase]
@@ -822,6 +822,25 @@
   ## empty_query=*:*
 
 
+###########################################################################
+# Settings to configure Solr Indexer
+###########################################################################
+
+[indexer]
+
+  # Location of the solrctl binary.
+  ## solrctl_path=/usr/bin/solrctl
+
+  # Location of the solr home.
+  ## solr_home=/usr/lib/solr
+
+  # Zookeeper ensemble.
+  ## solr_zk_ensemble=localhost:2181/solr
+
+  # The contents of this directory will be copied over to the solrctl host to its temporary directory.
+  ## config_template_path=/../hue/desktop/libs/indexer/src/data/solr_configs
+
+
 ###########################################################################
 # Settings to configure Job Designer
 ###########################################################################

+ 20 - 20
desktop/conf/pseudo-distributed.ini.tmpl

@@ -832,7 +832,7 @@
 
 
 ###########################################################################
-# Settings to configure Hbase
+# Settings to configure HBase Browser
 ###########################################################################
 
 [hbase]
@@ -849,25 +849,6 @@
   ## thrift_transport=buffered
 
 
-###########################################################################
-# Settings to configure Solr Collection Manager
-###########################################################################
-
-[collectionmanager]
-
-  # Batch indexer path in HDFS.
-  ## batch_indexer_path=/var/lib/search/search-mr-job.jar
-
-  # Location of the solrctl binary.
-  ## solrctl_path=/usr/lib/solr/bin/solrctl
-
-  # Location of the solr home.
-  ## solr_home=/usr/lib/solr
-
-  # Zookeeper ensemble.
-  ## solr_zk_ensemble=localhost:2181/solr
-
-
 ###########################################################################
 # Settings to configure Solr Search
 ###########################################################################
@@ -884,6 +865,25 @@
   ## empty_query=*:*
 
 
+###########################################################################
+# Settings to configure Solr Indexer
+###########################################################################
+
+[indexer]
+
+  # Location of the solrctl binary.
+  ## solrctl_path=/usr/bin/solrctl
+
+  # Location of the solr home.
+  ## solr_home=/usr/lib/solr
+
+  # Zookeeper ensemble.
+  ## solr_zk_ensemble=localhost:2181/solr
+
+  # The contents of this directory will be copied over to the solrctl host to its temporary directory.
+  ## config_template_path=/../hue/desktop/libs/indexer/src/data/solr_configs
+
+
 ###########################################################################
 # Settings to configure Job Designer
 ###########################################################################

+ 1 - 1
desktop/core/src/desktop/views.py

@@ -370,7 +370,7 @@ def commonheader(title, section, user, padding="90px"):
     for app in apps:
       if app.display_name not in [
           'beeswax', 'impala', 'pig', 'jobsub', 'jobbrowser', 'metastore', 'hbase', 'sqoop', 'oozie', 'filebrowser',
-          'useradmin', 'search', 'help', 'about', 'zookeeper', 'proxy', 'rdbms', 'spark']:
+          'useradmin', 'search', 'help', 'about', 'zookeeper', 'proxy', 'rdbms', 'spark'] and app.display_name != 'indexer':
         other_apps.append(app)
       if section == app.display_name:
         current_app = app

+ 1 - 1
desktop/libs/indexer/setup.py

@@ -20,7 +20,7 @@ setup(
       version = "1.0",
       author = "Hue",
       url = 'http://github.com/cloudera/hue',
-      description = "Collections manager for Cloudera Search",
+      description = "Collections manager for Search",
       packages = find_packages('src'),
       package_dir = {'': 'src'},
       install_requires = ['setuptools', 'desktop'],

+ 1 - 0
desktop/libs/indexer/src/indexer/conf.py

@@ -22,6 +22,7 @@ from django.utils.translation import ugettext_lazy as _t
 from desktop.lib.conf import Config
 
 
+# Unused
 BATCH_INDEXER_PATH = Config(
   key="batch_indexer_path",
   help=_t("Batch indexer path in HDFS."),

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

@@ -31,7 +31,7 @@ from indexer import conf, utils
 
 
 LOG = logging.getLogger(__name__)
-MAX_UPLOAD_SIZE = 10*1024*1024 # 10 MB
+MAX_UPLOAD_SIZE = 100 * 1024 * 1024 # 100 MB
 ALLOWED_FIELD_ATTRIBUTES = set(['name', 'type', 'indexed', 'stored'])
 FLAGS = [('I', 'indexed'), ('T', 'tokenized'), ('S', 'stored')]
 

+ 35 - 16
desktop/libs/indexer/src/indexer/templates/collections.mako

@@ -56,8 +56,15 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
 </style>
 
 
-<div class="search-bar" style="height: 30px">
-  <h4><a href="#manage">${_('Collection Manager')}</a></h4>
+<div class="search-bar" style="height: 30px">  
+  <div>
+    <div class="pull-right" style="padding-right:50px">  
+      <a class="btn" href="${ url('search:admin_collections') }" title="${ _('Collections') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}">
+        <i class="fa fa-tags"></i> ${ _('Dashboards') }
+      </a>
+    </div>  
+    <h4><a href="#manage">${_('Solr Indexer')}</a></h4>
+  </div>
 </div>
 
 
@@ -118,9 +125,15 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
       <%actionbar:render>
         <%def name="search()">
           <div data-bind="visible: collections().length > 0 && !isLoading()">
-            <input type="text" data-bind="filter: { 'list': collections, 'filteredList': filteredCollections, 'test': filterTest }" placeholder="${_('Filter dashboard')}" class="input-xlarge search-query">
-            <button data-bind="click: removeCollections, clickBubble: false, disable: selectedCollections().length == 0" class="btn toolbarBtn" title="${_('Delete the selected collections')}" disabled="disabled"><i class="fa fa-times"></i> ${_('Delete collections')}</button>
-            <a href="#create" class="btn toolbarBtn pull-right">${_('Add collection')}</a>
+            <input type="text" data-bind="filter: { 'list': collections, 'filteredList': filteredCollections, 'test': filterTest }"
+                placeholder="${_('Filter collections...')}" class="input-xlarge search-query">
+            <button data-bind="click: removeCollections, clickBubble: false, disable: selectedCollections().length == 0" class="btn toolbarBtn" 
+                title="${_('Delete the selected collections')}" disabled="disabled">
+              <i class="fa fa-times"></i> ${_('Delete')}
+            </button>
+            <a href="#create" class="btn toolbarBtn pull-right">
+              <i class="fa fa-plus-circle"></i> ${_('Create')}
+            </a>
           </div>
         </%def>
 
@@ -149,7 +162,7 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
                 <td data-bind="click: $parent.toggleCollectionSelect.bind($parent), clickBubble: false">
                   <span data-bind="css: {'fa-check': $parent.filteredCollections()[$index()].selected()}" class="hueCheckbox fa"></span>
                 </td>
-                <td data-bind="text: name"></td>
+                <td data-bind="text: name" style="cursor: pointer"></td>
               </tr>
             </tbody>
           </table>
@@ -182,6 +195,9 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
 
 <!-- Create wizard -->
 <script type="text/html" id="create-collection-data">
+  <div class="alert alert-info">
+    ${ _('Pick a name and a CSV or Tab separated file with header to index from HDFS') }
+  </div>
   <div class="control-group" data-bind="css: {'error': collection.name.errors().length > 0}">
     <label for="name" class="control-label">${_("Name")}</label>
     <div class="controls">
@@ -192,11 +208,11 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
   <div class="control-group" data-bind="css: {'error': file.errors().length > 0}">
     <label for="name" class="control-label">${_("Files")}</label>
     <div class="controls">
-      <input data-bind="value: file" type="text" class="span7 fileChooser" placeholder="/user/foo/data.csv"/>
+      <input data-bind="value: file" type="text" class="input-xxlarge fileChooser" placeholder="/user/hue/data.csv"/>
     </div>
   </div>
 
-  <div class="control-group" data-bind="css: {'error': sourceType.errors().length > 0}">
+  <div class="control-group hide" data-bind="css: {'error': sourceType.errors().length > 0}">
     <label for="name" class="control-label">${_("Source type")}</label>
     <div class="controls">
       <select data-bind="options: sourceTypes, value: sourceType" name="type"></select>
@@ -205,6 +221,9 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
 </script>
 
 <script type="text/html" id="create-collection-data-separated">
+  <div class="alert alert-info">
+    ${ _('Format of the selected file to index') }
+  </div>
   <div class="control-group" data-bind="css: {'error': fieldSeparator.errors().length > 0}">
     <label for="separator" class="control-label">${_("Separator")}</label>
     <div class="controls">
@@ -267,7 +286,7 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
           </p>
         </td>
         <td>
-          <a data-bind="click: remove, visible: editable" href="javascript:void(0)" class="btn btn-danger"><i class="fa fa-minus"></i>&nbsp;${_("Remove")}</a>
+          <a data-bind="click: remove, visible: editable" href="javascript:void(0)" class="btn"><i class="fa fa-minus"></i></a>
         </td>
       </tr>
     </tbody>
@@ -275,7 +294,7 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
 
   <br style="clear: both" />
   <br />
-  <a data-bind="click: collection.newField" href="javascript:void(0)" class="btn btn-info"><i class="fa fa-plus"></i>&nbsp;${_("Add field")}</a>
+  <a data-bind="click: collection.newField" href="javascript:void(0)" class="btn btn-info"><i class="fa fa-plus"></i>&nbsp;${_("Add")}</a>
 </script>
 <!--/ Create wizard -->
 <!--/ Create by file -->
@@ -286,9 +305,9 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
   <div data-bind="with: edit" class="sidebar-nav card-small">
     <ul class="nav nav-list">
       <li class="nav-header">${_('Actions')}</li>
-      <li><a data-bind="routie: 'edit/' + collection().name() + '/upload'" href="javascript:void(0)"><i class="fa fa-arrow-circle-o-up"></i> ${_('Upload data')}</a></li>
-      <li><a href=""><i class="fa fa-list"></i> ${ _('Search data') }</a></li>
-      <li><a data-bind="click: removeCollection, clickBubble: false" href="javascript:void(0)"><i class="fa fa-trash-o"></i> ${_('Remove collection')}</a></li>
+      <li><a data-bind="attr: { href: '/search/browse/' + collection().name() }"><i class="fa fa-search"></i> ${ _('Search') }</a></li>
+      <li><a data-bind="routie: 'edit/' + collection().name() + '/upload'" href="javascript:void(0)"><i class="fa fa-folder-open-o"></i> ${_('Index file')}</a></li>      
+      <li><a data-bind="click: removeCollection, clickBubble: false" href="javascript:void(0)"><i class="fa fa-times"></i> ${_('Delete')}</a></li>
     </ul>
   </div>
 </div>
@@ -330,11 +349,11 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
               <td><p class="text-center"><input data-bind="checked: required" type="checkbox"></p></td>
               <td><p class="text-center"><input data-bind="checked: indexed" type="checkbox"></p></td>
               <td><p class="text-center"><input data-bind="checked: stored" type="checkbox"></p></td>
-              <td><a data-bind="click: remove" href="javascript:void(0)" class="btn btn-danger nowrap"><i class="fa fa-minus"></i>&nbsp;${_("Remove field")}</a></td>
+              <td><a data-bind="click: remove" href="javascript:void(0)" class="btn btn-danger nowrap"><i class="fa fa-minus"></i></a></td>
             </tr>
           </tbody>
         </table>
-        <a data-bind="click: collection().newField" href="javascript:void(0)" class="btn btn-info"><i class="fa fa-plus"></i>&nbsp;${_("Add field")}</a>
+        <a data-bind="click: collection().newField" href="javascript:void(0)" class="btn btn-info"><i class="fa fa-plus"></i>&nbsp;${_("Add")}</a>
         <br />
         <br />
         <br />
@@ -368,7 +387,7 @@ ${ commonheader(_('Collection Manager'), "indexer", user, "29px") | n,unicode }
   <div class="control-group" data-bind="css: {'error': file.errors().length > 0}">
     <label for="name" class="control-label">${_("Files")}</label>
     <div class="controls">
-      <input data-bind="value: file" type="text" class="span7 fileChooser" placeholder="/user/foo/data.csv"/>
+      <input data-bind="value: file" type="text" class="span7 fileChooser" placeholder="/user/hue/data.csv"/>
     </div>
   </div>