Browse Source

HUE-5149 [metadata] Avoid error on list_tags

Romain Rigaux 9 years ago
parent
commit
7869628c40

+ 3 - 1
desktop/libs/metadata/src/metadata/navigator_api.py

@@ -233,8 +233,9 @@ def search_entities_interactive(request):
   for record in response.get('results'):
     record['hue_description'] = ''
     record['hue_name'] = (record.get('parentPath', '').replace('/', '.') + '.').lstrip('.')
+    name = record.get('originalName', '')
     for term in ts:
-      record['hue_name'] += _highlight(term, record.get('originalName', ''))
+      name += _highlight(term, name)
       for tag in record.get('tags', []):
         if re.match(term, tag):
           record['hue_description'] += ' tags:%s' % _highlight(term, tag)
@@ -242,6 +243,7 @@ def search_entities_interactive(request):
       if record.get(fname, ''):
         record['hue_description'] += ' %s:%s' % (fname, _highlight(fval, record[fname]))
 
+    record['hue_name'] += name
     record['hue_name'] = escape(record['hue_name']).replace('&lt;em&gt;', '<em>').replace('&lt;/em&gt;', '</em>')
     record['hue_description'] = escape(record['hue_description']).replace('&lt;em&gt;', '<em>').replace('&lt;/em&gt;', '</em>')
 

+ 2 - 1
desktop/libs/metadata/src/metadata/navigator_client.py

@@ -172,7 +172,8 @@ class NavigatorApi(object):
             filterQueries.append(term)
 
       body = {'query': ' '.join(query) or '*'}
-      filterQueries += ['{!tag=type} %s' % ' OR '.join(['type:%s' % fq for fq in fq_type])]
+      if fq_type:
+        filterQueries += ['{!tag=type} %s' % ' OR '.join(['type:%s' % fq for fq in fq_type])]
 
       body['facetFields'] = facetFields or [] # Currently mandatory in API
       if facetPrefix: