浏览代码

HUE-5116 [solr] Allow indexing of records with missing fields

Romain Rigaux 9 年之前
父节点
当前提交
5241edc
共有 2 个文件被更改,包括 3 次插入2 次删除
  1. 2 1
      desktop/libs/indexer/src/indexer/controller.py
  2. 1 1
      desktop/libs/indexer/src/indexer/utils.py

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

@@ -18,6 +18,7 @@
 
 import json
 import logging
+import numbers
 import os
 import shutil
 
@@ -284,7 +285,7 @@ class CollectionManagerController(object):
           dataset = tablib.Dataset()
           dataset.append(columns)
           for i, row in enumerate(result['data']):
-            dataset.append([ROW_COUNT + i] + row)
+            dataset.append([ROW_COUNT + i] + [cell if cell else (0 if isinstance(cell, numbers.Number) else '') for cell in row])
 
           if not api.update(collection_or_core_name, dataset.csv, content_type='csv'):
             raise PopupException(_('Could not update index. Check error logs for more info.'))

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

@@ -47,7 +47,7 @@ DEFAULT_FIELD = {
   'type': 'text',
   'indexed': 'true',
   'stored': 'true',
-  'required': 'true',
+  'required': 'false',
   'multiValued': 'false'
 }