Browse Source

HUE-2461 [search] Better delimiter than : for 2d selection in heatmap

Romain Rigaux 10 years ago
parent
commit
4a7ba4161d

+ 5 - 4
apps/search/src/search/models.py

@@ -618,8 +618,8 @@ def _augment_pivot_2d(name, facet_id, counts, selected_values):
       count[pivot['value']] = pivot['count']
       pivot_field = pivot['field']
     for val in values:
-      fq_values = '%s:%s' % (dimension['value'], val)
-      fq_fields = '%s:%s' % (dimension['field'], pivot_field)
+      fq_values = [dimension['value'], val]
+      fq_fields = [dimension['field'], pivot_field]
       fq_filter = selected_values.get(facet_id, [])
       _selected_values = [f['value'] for f in fq_filter]
 
@@ -639,8 +639,9 @@ def _augment_pivot_2d(name, facet_id, counts, selected_values):
 def _augment_pivot_nd(facet_id, counts, selected_values, fields='', values=''):
 
   for c in counts:
-    fq_fields = (fields + ':' if fields else '') + c['field']
-    fq_values = (smart_str(values) + ':' if values else '') + smart_str(c['value'])
+    fq_fields = (fields if fields else []) + [c['field']]
+    fq_values = (values if values else []) + [smart_str(c['value'])]
+
     if 'pivot' in c:
       _augment_pivot_nd(facet_id, c['pivot'], selected_values, fq_fields, fq_values)
 

+ 1 - 1
apps/search/src/search/static/search/js/search.ko.js

@@ -120,7 +120,7 @@ var Query = function (vm, query) {
     } else {
       $.each(self.fqs(), function (index, fq) {
         if (fq.id() == data.widget_id) {
-          var f = $.grep(fq.filter(), function(f) { return f.value() == data.facet.value; });
+          var f = $.grep(fq.filter(), function(f) { return JSON.stringify(f.value()) == JSON.stringify(data.facet.value); });
           if (f.length > 0) {
             fq.filter.remove(f[0]);
             if (fq.filter().length == 0) {

+ 2 - 2
desktop/libs/libsolr/src/libsolr/api.py

@@ -80,11 +80,11 @@ class SolrApi(object):
 
     for fq in merged_fqs:
       if fq['type'] == 'field':
-        fields = fq['field'].split(':') # 2D facets support
+        fields = fq['field'] if type(fq['field']) == list else [fq['field']] # 2D facets support
         for field in fields:
           f = []
           for _filter in fq['filter']:
-            values = _filter['value'].split(':') if len(fields) > 1 else [_filter['value']]
+            values = _filter['value'] if type(_filter['value']) == list else [_filter['value']] # 2D facets support
             if fields.index(field) < len(values): # Lowest common field denominator
               value = values[fields.index(field)]
               exclude = '-' if _filter['exclude'] else ''