Commit 0b6f675c authored by Gergely Ujvari's avatar Gergely Ujvari

Do not normalize searchfilter sent to the backend.

We have every analyzers setup for ES to do that more precisely.
parent 6eef7b3d
...@@ -43,14 +43,6 @@ class SearchFilter ...@@ -43,14 +43,6 @@ class SearchFilter
tokens tokens
# Converts a string into lowercase and asciifolds
this.$inject = ['stringHelpers']
constructor: (stringHelpers) ->
@_normalize = (str) ->
if typeof str is 'string'
return stringHelpers.unidecode(str.toLowerCase())
else return str
# This function will generate the facets from the search-text input # This function will generate the facets from the search-text input
# It'll first tokenize it and then sorts them into facet lists # It'll first tokenize it and then sorts them into facet lists
# The output will be a dict with the following structure: # The output will be a dict with the following structure:
...@@ -82,7 +74,7 @@ class SearchFilter ...@@ -82,7 +74,7 @@ class SearchFilter
filter = term.slice 0, term.indexOf ":" filter = term.slice 0, term.indexOf ":"
unless filter? then filter = "" unless filter? then filter = ""
switch filter switch filter
when 'quote' then quote.push @_normalize term[6..] when 'quote' then quote.push term[6..]
when 'result' then result.push term[7..] when 'result' then result.push term[7..]
when 'since' when 'since'
# We'll turn this into seconds # We'll turn this into seconds
...@@ -118,11 +110,11 @@ class SearchFilter ...@@ -118,11 +110,11 @@ class SearchFilter
# Time given in year # Time given in year
t = /^(\d+)year$/.exec(time)[1] t = /^(\d+)year$/.exec(time)[1]
since.push t * 60 * 60 * 24 * 365 since.push t * 60 * 60 * 24 * 365
when 'tag' then tag.push @_normalize term[4..] when 'tag' then tag.push term[4..]
when 'text' then text.push @_normalize term[5..] when 'text' then text.push term[5..]
when 'uri' then uri.push @_normalize term[4..] when 'uri' then uri.push term[4..]
when 'user' then user.push @_normalize term[5..] when 'user' then user.push term[5..]
else any.push @_normalize term else any.push term
any: any:
terms: any terms: any
......
...@@ -507,6 +507,14 @@ class ViewFilter ...@@ -507,6 +507,14 @@ class ViewFilter
limit = Math.min((filters.result?.terms or [])...) limit = Math.min((filters.result?.terms or [])...)
count = 0 count = 0
# Normalizing the filters, need to do only once.
for _, filter of filters
if filter.terms
filter.terms = filter.terms.map (e) =>
e = e.toLowerCase()
e = @_normalize e
e
for annotation in annotations for annotation in annotations
break if count >= limit break if count >= limit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment