소스 검색

HUE-3988 [search] Support schemaless collections

Romain Rigaux 9 년 전
부모
커밋
509733e
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      apps/search/src/search/models.py

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

@@ -533,8 +533,11 @@ class Collection2(object):
   def get_default(self, user, name):
     fields = self.fields_data(user, name)
     id_field = [field['name'] for field in fields if field.get('isId')]
+
     if id_field:
       id_field = id_field[0]
+    else:
+      id_field = '' # Schemaless might not have an id
 
     TEMPLATE = {
       "extracode": escape("<style type=\"text/css\">\nem {\n  font-weight: bold;\n  background-color: yellow;\n}</style>\n\n<script>\n</script>"),
@@ -860,6 +863,7 @@ def augment_solr_response(response, collection, query):
   # HTML escaping
   if not query.get('download'):
     id_field = collection.get('idField', '')
+
     for doc in response['response']['docs']:
       for field, value in doc.iteritems():
         if isinstance(value, numbers.Number):