Browse Source

[search] Set a default field type for each field

Romain Rigaux 10 years ago
parent
commit
e2d1d60
2 changed files with 4 additions and 1 deletions
  1. 3 0
      apps/search/src/search/models.py
  2. 1 1
      apps/search/src/search/templates/search.mako

+ 3 - 0
apps/search/src/search/models.py

@@ -484,6 +484,9 @@ class Collection2(object):
       }
     if 'suggest' not in props['collection']:
       props['collection']['suggest'] = {'enabled': False, 'dictionary': ''}
+    for field in props['collection']['template']['fieldsAttributes']:
+      if 'type' not in field:
+        field['type'] = 'string'
 
     for facet in props['collection']['facets']:
       properties = facet['properties']

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

@@ -657,7 +657,7 @@ ${ dashboard.layout_skeleton() }
           <div style="margin-bottom: 3px; white-space: nowrap">
             <i class="fa fa-question-circle pull-right muted pointer analysis" data-bind="click: function() { $root.fieldAnalysesName(name()); $root.showFieldAnalysis(); }, attr:{'title': '${ _ko('Click to analyze field') } ' + name()}"></i>
             <input type="checkbox" data-bind="checkedValue: name, checked: $root.collection.template.fieldsSelected" style="margin: 0" />
-            <div data-bind="text: name, css:{'field-selector': true, 'hoverable': $root.collection.template.fieldsSelected.indexOf(name()) > -1}, click: highlightColumn" style="margin-right: 10px"></div>
+            <div data-bind="text: type, css:{'field-selector': true, 'hoverable': $root.collection.template.fieldsSelected.indexOf(name()) > -1}, click: highlightColumn" style="margin-right: 10px"></div>
           </div>
         </div>
         <div data-bind="visible: $root.collection.template.filteredAttributeFields().length == 0" style="padding-left: 4px; padding-top: 5px; font-size: 40px; color: #CCC">