浏览代码

[indexer] All fields should be indexed by default

String type should be detected for strings with 4 or less words.
Abraham Elmahrek 11 年之前
父节点
当前提交
66872a2
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 6 1
      desktop/libs/indexer/src/indexer/utils.py
  2. 1 3
      desktop/libs/indexer/static/js/lib.js

+ 6 - 1
desktop/libs/indexer/src/indexer/utils.py

@@ -106,11 +106,16 @@ def get_field_types(row):
     if len(bin(int(value))) - 2 > 32:
       raise ValueError()
 
+  def test_string(value):
+    if len(smart_str(value).split(' ')) > 4:
+      raise ValueError()
+
   test_fns = [('tint', test_int),
               ('tlong', int),
               ('tdouble', float),
               ('boolean', test_boolean),
-              ('tdate', test_timestamp)]
+              ('tdate', test_timestamp),
+              ('string', test_string)]
   field_types = []
   for field in row:
     field_type = None

+ 1 - 3
desktop/libs/indexer/static/js/lib.js

@@ -49,9 +49,7 @@ var Collection = function(name) {
 var Field = function(collection, name, type, required, indexed, stored) {
   var self = this;
 
-  if (indexed == undefined) {
-    indexed = type.indexOf('text_') == -1;
-  }
+  indexed = (indexed == undefined) ? true : !!indexed;
   required = (required == undefined) ? true : !!required;
 
   self.name = ko.observable(name).extend({'errors': null});