Github user tbouron commented on a diff in the pull request: https://github.com/apache/brooklyn-ui/pull/96#discussion_r230340646 --- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js --- @@ -88,23 +89,42 @@ export function catalogSelectorSearchFilter() { return function (items, search) { if (search) { return items.filter(function (item) { - return search.toLowerCase().split(' ').reduce( (found, part) => - found && - FIELDS_TO_SEARCH - .filter(field => item.hasOwnProperty(field) && item[field]) - .reduce((match, field) => { + item.relevance = 0; + let wordNum = 0; + return search.toLowerCase().split(' ').reduce( (found, part) => { + wordNum++; + let fieldNum = 0; + return found && + FIELDS_TO_SEARCH.reduce((match, field) => { if (match) return true; + fieldNum++; + if (!item.hasOwnProperty(field) || !item[field]) return false; let text = item[field]; if (!text.toLowerCase) { text = JSON.stringify(text).toLowerCase(); } else { text = text.toLowerCase(); } - return match || text.indexOf(part) > -1; + let index = text.indexOf(part); + if (index == -1) return false; --- End diff -- Same a above
---