浏览代码

HUE-5116 [search] Number of buckets for 1 dimension

Romain Rigaux 9 年之前
父节点
当前提交
b179dc1

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

@@ -922,7 +922,7 @@ def augment_solr_response(response, collection, query):
           'counts': counts,
           'extraSeries': extraSeries,
           'dimension': dimension,
-          'response': {'response': {'start': 0, 'numFound': len(rows)}},
+          'response': {'response': {'start': 0, 'numFound': response['facets'][name]['numBuckets']}}, # Todo * nested buckets + offsets
           'docs': [dict(zip(cols, row)) for row in rows],
           'fieldsAttributes': [Collection2._make_gridlayout_header_field({'name': col, 'type': 'aggr' if '(' in col else 'string'}) for col in cols]
         }

+ 1 - 1
desktop/core/src/desktop/templates/responsive.mako

@@ -169,7 +169,7 @@ ${ hueIcons.symbols() }
         </svg>
       </a>
       <div class="compose-action btn-group">
-        <button class="btn" data-bind="click: function(){ onePageViewModel.changeEditorType('hive'); onePageViewModel.currentApp('editor') }" title="${ _('Compose a query') }">${ _('Compose') }</button>
+        <button class="btn" data-bind="click: function(){ onePageViewModel.changeEditorType('hive'); onePageViewModel.currentApp('editor') }" title="${ _('Open editor') }">${ _('Compose') }</button>
         <button class="btn dropdown-toggle" data-toggle="dropdown">
           <span class="caret"></span>
         </button>

+ 11 - 3
desktop/libs/libsolr/src/libsolr/api.py

@@ -145,6 +145,7 @@ class SolrApi(object):
               'mincount': int(facet['properties']['mincount']),
               'sort': {'count': facet['properties']['sort']},
           }
+          print facet
 
           if facet['properties']['domain'].get('blockParent') or facet['properties']['domain'].get('blockChildren'):
             _f['domain'] = {}
@@ -162,11 +163,15 @@ class SolrApi(object):
             })
             if timeFilter and timeFilter['time_field'] == facet['field'] and (facet['id'] not in timeFilter['time_filter_overrides'] or facet['widgetType'] != 'bucket-widget'):
               _f.update(self._get_time_filter_query(timeFilter, facet))
-          else:
+          else:            
             _f.update({
                 'type': 'terms',
                 'field': facet['field'],
-                'excludeTags': facet['id']
+                'excludeTags': facet['id'],
+                'offset': 0,
+                'numBuckets': True,
+                'allBuckets': True,
+                'prefix': ''
             })
             if facet['properties']['canRange'] and not facet['properties']['isDate']:
               del _f['mincount'] # Numeric fields do not support
@@ -267,7 +272,10 @@ class SolrApi(object):
           'type': 'terms',
           'field': '%(field)s' % facet,
           'limit': int(facet.get('limit', 10)),
-          'mincount': int(facet['mincount'])
+          'mincount': int(facet['mincount']),
+          'numBuckets': True,
+          'allBuckets': True,
+          'prefix': ''
       }
       if widget['widgetType'] == 'tree2-widget' and facets[-1]['aggregate']['function'] != 'count':
         _f['subcount'] = self._get_aggregate_function(facets[-1])