diff --git a/awx/ui/client/src/shared/smart-search/queryset.service.js b/awx/ui/client/src/shared/smart-search/queryset.service.js index d00ec0c242..1571ab936d 100644 --- a/awx/ui/client/src/shared/smart-search/queryset.service.js +++ b/awx/ui/client/src/shared/smart-search/queryset.service.js @@ -93,7 +93,7 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear } else if(params.relatedSearchTerm) { if(params.singleSearchParam) { - paramString += keySplit[0] + '__search'; + paramString += keySplit[0]; } else { paramString += keySplit[0] + '__search_DEFAULT'; diff --git a/awx/ui/client/src/shared/smart-search/smart-search.controller.js b/awx/ui/client/src/shared/smart-search/smart-search.controller.js index 6f5488ad1d..a673d0e783 100644 --- a/awx/ui/client/src/shared/smart-search/smart-search.controller.js +++ b/awx/ui/client/src/shared/smart-search/smart-search.controller.js @@ -193,7 +193,22 @@ export default ['$stateParams', '$scope', '$state', 'GetBasePath', 'QuerySet', ' params = _.merge(params, searchWithoutKey(term), combineSameSearches); } else { - params = _.merge(params, qs.encodeParam({term: term, searchTerm: true, singleSearchParam: $scope.singleSearchParam ? $scope.singleSearchParam : false}), combineSameSearches); + let root = termParts[0].split(".")[0].replace(/^-/, ''); + if(_.has($scope.models[$scope.list.name].base, root)) { + if($scope.models[$scope.list.name].base[root].type && $scope.models[$scope.list.name].base[root].type === 'field') { + params = _.merge(params, qs.encodeParam({term: term, relatedSearchTerm: true, singleSearchParam: $scope.singleSearchParam ? $scope.singleSearchParam : false}), combineSameSearches); + } + else { + params = _.merge(params, qs.encodeParam({term: term, searchTerm: true, singleSearchParam: $scope.singleSearchParam ? $scope.singleSearchParam : false}), combineSameSearches); + } + } + else if(_.contains($scope.models[$scope.list.name].related, root)) { + params = _.merge(params, qs.encodeParam({term: term, relatedSearchTerm: true, singleSearchParam: $scope.singleSearchParam ? $scope.singleSearchParam : false}), combineSameSearches); + } + // Its not a search term or a related search term - treat it as a string + else { + params = _.merge(params, searchWithoutKey(term), combineSameSearches); + } } }