From 739fa423c5669a6f5d65ca744923421b78565acb Mon Sep 17 00:00:00 2001 From: shale Date: Tue, 21 Jul 2015 16:10:35 -0700 Subject: [PATCH] [Search] Added wildcards to generic Added wildcard support to the generic search provider. In this case, wildcards behave just like spaces. --- .../search/src/controllers/SearchController.js | 2 +- .../src/providers/ElasticsearchSearchProvider.js | 1 - .../search/src/providers/GenericSearchProvider.js | 1 - .../features/search/src/workers/GenericSearchWorker.js | 10 ++++++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/platform/features/search/src/controllers/SearchController.js b/platform/features/search/src/controllers/SearchController.js index 74aad0b464..34104c5aa0 100644 --- a/platform/features/search/src/controllers/SearchController.js +++ b/platform/features/search/src/controllers/SearchController.js @@ -27,7 +27,7 @@ define(function () { "use strict"; - var INITIAL_LOAD_NUMBER = 5, + var INITIAL_LOAD_NUMBER = 20, LOAD_INCREMENT = 5; function SearchController($scope, $timeout, searchService) { diff --git a/platform/features/search/src/providers/ElasticsearchSearchProvider.js b/platform/features/search/src/providers/ElasticsearchSearchProvider.js index f34941023d..427e44ebf6 100644 --- a/platform/features/search/src/providers/ElasticsearchSearchProvider.js +++ b/platform/features/search/src/providers/ElasticsearchSearchProvider.js @@ -186,7 +186,6 @@ define( * Notes: * * The order of the results is from highest to lowest score, * as elsaticsearch determines them to be. - * * Wildcards are supported. * * Fuzziness is used to produce more results that are still * relevant. (All results within a certain edit distance.) * * More search details at diff --git a/platform/features/search/src/providers/GenericSearchProvider.js b/platform/features/search/src/providers/GenericSearchProvider.js index 04e2ff65b5..c478bbaaf1 100644 --- a/platform/features/search/src/providers/GenericSearchProvider.js +++ b/platform/features/search/src/providers/GenericSearchProvider.js @@ -182,7 +182,6 @@ define( * (which are generated by splitting the input at spaces). * * Scores are higher for matches that have more than one of * the terms as substrings. - * * Wildcards are not (yet?) supported. * * @param inputID the name of the ID property of the html text * input where this funcion should find the search term diff --git a/platform/features/search/src/workers/GenericSearchWorker.js b/platform/features/search/src/workers/GenericSearchWorker.js index 336c2e1222..5674ce9ac4 100644 --- a/platform/features/search/src/workers/GenericSearchWorker.js +++ b/platform/features/search/src/workers/GenericSearchWorker.js @@ -76,8 +76,14 @@ terms = terms.substring(0, terms.length - 1); } - // Then split it at the spaces - terms = terms.split(' '); + // Then split it at spaces and asterisks + terms = terms.split(/ |\*/); + + // Remove any empty strings from the terms + while (terms.indexOf('') !== -1) { + terms.splice(terms.indexOf(''), 1); + } + return terms; }