Permalink
Browse files

Fixed issue #2195 - Search with id:123 does not work anymore (fixes #…

  • Loading branch information...
SummerStorm committed Oct 2, 2018
1 parent f15ac3b commit bfccecc0122bc76e5e627455e312df3aaf70743c
Showing with 27 additions and 10 deletions.
  1. +3 −2 lib/search_index_backend.rb
  2. +24 −8 test/unit/search_index_backend_test.rb
@@ -347,6 +347,7 @@ def self.search_by_index(query, limit = 10, index = nil, query_extention = {}, f
'query_string' => {
'query' => append_wildcard_to_simple_query(query),
'default_operator' => 'AND',
'analyze_wildcard' => true,
}
}
data['query']['bool']['must'].push condition
@@ -728,10 +729,10 @@ def self.humanized_error(verb:, url:, payload: nil, response:)
result
end
# add * on simple query like "somephrase23" or "attribute: somephrase23"
# add * on simple query like "somephrase23"
def self.append_wildcard_to_simple_query(query)
query.strip!
query += '*' if query.match?(/^([[:alnum:]._]+|[[:alnum:]]+\:\s*[[:alnum:]._]+)$/)
query += '*' if !query.match?(/:/)
query
end
end
@@ -28,6 +28,22 @@ def clean_queries(query_string)
article.from: bob # also article.from can be used
article.body: heat~ # using the fuzzy operator will also find terms that are similar, in this case also “head”
article.body: /joh?n(ath[oa]n)/ # using regular expressions
user:M
user:Max
user:Max.
user:Max*
organization:A_B
organization:A_B*
user: M
user: Max
user: Max.
user: Max*
organization: A_B
organization: A_B*
id:123
number:123
id:"123"
number:"123"
)
simple_queries = clean_queries %(
@@ -38,14 +54,14 @@ def clean_queries(query_string)
A_B
äöü
123
user:M
user:Max
user:Max.
organization:A_B
user: M
user: Max
user: Max.
organization: A_B
*ax # wildcards are allowed in simple queries
Max*
M*x
M?x
test@example.com
test@example.
test@example
test@
)
complex_queries.each do |query|

0 comments on commit bfccecc

Please sign in to comment.