mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 00:11:22 +08:00
Fix query generation for boolean search [SCI-12350]
This commit is contained in:
parent
e508df0ccc
commit
c9ec2bf09f
1 changed files with 5 additions and 1 deletions
|
|
@ -113,8 +113,9 @@ module SearchableModel
|
|||
|
||||
query_clauses = []
|
||||
query_params = []
|
||||
search_tokens = tokenize_search_query(query)
|
||||
|
||||
tokenize_search_query(query).each_with_index do |token, index|
|
||||
search_tokens.each_with_index do |token, index|
|
||||
if token[:type] == :keyword
|
||||
exact_match = token[:value].split.size > 1
|
||||
like = exact_match ? '~' : 'ILIKE'
|
||||
|
|
@ -145,6 +146,9 @@ module SearchableModel
|
|||
exact_match ? "(^|\\s)#{Regexp.escape(token[:value])}(\\s|$)" : "%#{sanitize_sql_like(token[:value])}%"
|
||||
end
|
||||
end
|
||||
|
||||
next_token = search_tokens[index + 1]
|
||||
query_clauses << ' AND ' if next_token && next_token[:type] == :keyword
|
||||
elsif token[:type] == :operator
|
||||
query_clauses <<
|
||||
case token[:value]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue