Fix ES error
This commit is contained in:
parent
d566ae4a3f
commit
0ad0dcc8fd
1 changed files with 23 additions and 1 deletions
|
@ -260,6 +260,7 @@ class SearchQueryTransformer < Parslet::Transform
|
||||||
@negated = operator == '-'
|
@negated = operator == '-'
|
||||||
@options = options
|
@options = options
|
||||||
@operator = :filter
|
@operator = :filter
|
||||||
|
@statuses_index_only = false
|
||||||
|
|
||||||
case prefix
|
case prefix
|
||||||
when 'has', 'is'
|
when 'has', 'is'
|
||||||
|
@ -296,6 +297,7 @@ class SearchQueryTransformer < Parslet::Transform
|
||||||
when 'my'
|
when 'my'
|
||||||
@type = :term
|
@type = :term
|
||||||
@term = @options[:current_account]&.id
|
@term = @options[:current_account]&.id
|
||||||
|
@statuses_index_only = true
|
||||||
case term
|
case term
|
||||||
when 'favourited', 'favorited', 'fav'
|
when 'favourited', 'favorited', 'fav'
|
||||||
@filter = :favourited_by
|
@filter = :favourited_by
|
||||||
|
@ -326,13 +328,33 @@ class SearchQueryTransformer < Parslet::Transform
|
||||||
else
|
else
|
||||||
'desc'
|
'desc'
|
||||||
end
|
end
|
||||||
|
when 'searchability'
|
||||||
|
@filter = :searchablity
|
||||||
|
@type = :terms
|
||||||
|
@statuses_index_only = true
|
||||||
|
@term = case term
|
||||||
|
when 'public'
|
||||||
|
%w(public private direct limited)
|
||||||
|
when 'private'
|
||||||
|
%w(private direct limited)
|
||||||
|
when 'direct'
|
||||||
|
%w(direct limited)
|
||||||
|
else
|
||||||
|
%w(limited)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
raise "Unknown prefix: #{prefix}"
|
raise "Unknown prefix: #{prefix}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_query
|
def to_query
|
||||||
if @negated
|
if @statuses_index_only
|
||||||
|
if @negated
|
||||||
|
{ bool: { must_not: [_index => StatusesIndex.index_name, @type => { @filter => @term }] } }
|
||||||
|
else
|
||||||
|
{ bool: { must: [_index => StatusesIndex.index_name, @type => { @filter => @term }] } }
|
||||||
|
end
|
||||||
|
elsif @negated
|
||||||
{ bool: { must_not: { @type => { @filter => @term } } } }
|
{ bool: { must_not: { @type => { @filter => @term } } } }
|
||||||
else
|
else
|
||||||
{ @type => { @filter => @term } }
|
{ @type => { @filter => @term } }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue