mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-10 13:59:56 +08:00
Fix search for exact phrases and with_subquery [SCI-12033]
This commit is contained in:
parent
6ae934cdb6
commit
a31976e590
1 changed files with 3 additions and 4 deletions
|
@ -157,7 +157,7 @@ module SearchableModel
|
||||||
phrase = phrase.to_s.strip
|
phrase = phrase.to_s.strip
|
||||||
|
|
||||||
case phrase.downcase
|
case phrase.downcase
|
||||||
when *%w(and or)
|
when 'and', 'or'
|
||||||
current_operator = phrase.downcase
|
current_operator = phrase.downcase
|
||||||
when 'not'
|
when 'not'
|
||||||
negate = true
|
negate = true
|
||||||
|
@ -201,13 +201,12 @@ module SearchableModel
|
||||||
i = (index * attrs.count) + i
|
i = (index * attrs.count) + i
|
||||||
|
|
||||||
new_phrase = exact_match ? phrase[1..-2] : phrase
|
new_phrase = exact_match ? phrase[1..-2] : phrase
|
||||||
if DATA_VECTOR_ATTRIBUTES.include?(attribute)
|
if DATA_VECTOR_ATTRIBUTES.include?(attribute) && !exact_match
|
||||||
new_phrase = new_phrase.strip.split(/\s+/)
|
new_phrase = new_phrase.strip.split(/\s+/)
|
||||||
new_phrase.map! { |t| "#{t}:*" } unless exact_match
|
new_phrase.map! { |t| "#{t}:*" }
|
||||||
else
|
else
|
||||||
new_phrase = exact_match ? "(^|\\s)#{Regexp.escape(new_phrase)}(\\s|$)" : "%#{sanitize_sql_like(new_phrase)}%"
|
new_phrase = exact_match ? "(^|\\s)#{Regexp.escape(new_phrase)}(\\s|$)" : "%#{sanitize_sql_like(new_phrase)}%"
|
||||||
end
|
end
|
||||||
|
|
||||||
[:"t#{i}", new_phrase]
|
[:"t#{i}", new_phrase]
|
||||||
end).to_h
|
end).to_h
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue