Browse Source

HUE-8327 [metadata] Enable searching on custom key-value pairs through the global search

Johan Ahlen 7 years ago
parent
commit
bfe90d0b66

+ 1 - 1
desktop/core/src/desktop/templates/ko_components/ko_global_search.mako

@@ -465,7 +465,7 @@ from desktop.views import _ko
           var navQuery = querySpec.query;
           // Add * in front of each term unless already there
           querySpec.text.forEach(function (textPart) {
-            if (textPart.indexOf('*') === -1 && navQuery.indexOf('*' + textPart) === -1) {
+            if (textPart.indexOf('*') === -1 && navQuery.indexOf('*' + textPart) === -1 && textPart.indexOf(':') === -1) {
               navQuery = navQuery.replace(textPart, '*' + textPart);
             }
           });

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

@@ -268,7 +268,11 @@ class NavigatorApi(object):
             if name == 'type': # Make sure type value still makes sense for the source
               term = '%s:%s' % (name, val.upper())
               fq_type = entity_types
-            filterQueries.append(term)
+            if name.lower() not in ['type', 'tags', 'owner', 'originalname', 'originaldescription', 'lastmodifiedby']:
+              # User Defined Properties are prefixed with 'up_', i.e. "department:sales" -> "up_department:sales"
+              query.append('up_' + term)
+            else:
+              filterQueries.append(term)
 
       filterQueries.append('deleted:false')