From 1d41bcd8253b502e14d900c933be6c6b98e9c22b Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Thu, 20 Jun 2019 16:02:48 +0100 Subject: [PATCH] prevent empty tokens in search index --- core/src/main/groovy/com/muwire/core/search/SearchIndex.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/groovy/com/muwire/core/search/SearchIndex.groovy b/core/src/main/groovy/com/muwire/core/search/SearchIndex.groovy index 76e734a9..61db4291 100644 --- a/core/src/main/groovy/com/muwire/core/search/SearchIndex.groovy +++ b/core/src/main/groovy/com/muwire/core/search/SearchIndex.groovy @@ -34,6 +34,9 @@ class SearchIndex { private static String[] split(String source) { source = source.replaceAll(Constants.SPLIT_PATTERN, " ").toLowerCase() source.split(" ") + def rv = [] + source.each { if (it.length() > 0) rv << it } + rv.toArray(new String[0]) } String[] search(List terms) {