From e81d871b013f29c11ec084e80497dd665e042073 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 24 Aug 2017 00:53:36 +0200 Subject: [PATCH] Append * on simple query like "somephrase23" or "attribute: somephrase23" --- lib/search_index_backend.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb index 8dcea57bb..128b4ffdc 100644 --- a/lib/search_index_backend.rb +++ b/lib/search_index_backend.rb @@ -198,9 +198,12 @@ return search result data['query']['bool']['must'] = [] end - # add * on simple query search - if query && query =~ /^[[:alpha:]]+$/ - query += '*' + # add * on simple query like "somephrase23" or "attribute: somephrase23" + if query.present? + query.strip! + if query =~ /^([[:alpha:],0-9]+|[[:alpha:]]+\:\s+[[:alpha:],0-9]+)$/ + query += '*' + end end # real search condition