|
|
@ -225,17 +225,16 @@ class SearchQueryTransformer < Parslet::Transform
|
|
|
|
rule(clause: subtree(:clause)) do
|
|
|
|
rule(clause: subtree(:clause)) do
|
|
|
|
prefix = clause[:prefix][:term].to_s if clause[:prefix]
|
|
|
|
prefix = clause[:prefix][:term].to_s if clause[:prefix]
|
|
|
|
operator = clause[:operator]&.to_s
|
|
|
|
operator = clause[:operator]&.to_s
|
|
|
|
|
|
|
|
term = clause[:phrase] ? clause[:phrase].map { |term| term[:term].to_s }.join(' ') : clause[:term].to_s
|
|
|
|
|
|
|
|
|
|
|
|
if clause[:prefix] && SUPPORTED_PREFIXES.include?(prefix)
|
|
|
|
if clause[:prefix] && SUPPORTED_PREFIXES.include?(prefix)
|
|
|
|
PrefixClause.new(prefix, operator, clause[:term].to_s, current_account: current_account)
|
|
|
|
PrefixClause.new(prefix, operator, term, current_account: current_account)
|
|
|
|
elsif clause[:prefix]
|
|
|
|
elsif clause[:prefix]
|
|
|
|
TermClause.new(operator, "#{prefix} #{clause[:term]}")
|
|
|
|
TermClause.new(operator, "#{prefix} #{term}")
|
|
|
|
elsif clause[:term]
|
|
|
|
elsif clause[:term]
|
|
|
|
TermClause.new(operator, clause[:term].to_s)
|
|
|
|
TermClause.new(operator, term)
|
|
|
|
elsif clause[:shortcode]
|
|
|
|
|
|
|
|
TermClause.new(operator, ":#{clause[:term]}:")
|
|
|
|
|
|
|
|
elsif clause[:phrase]
|
|
|
|
elsif clause[:phrase]
|
|
|
|
PhraseClause.new(operator, clause[:phrase].is_a?(Array) ? clause[:phrase].map { |p| p[:term].to_s }.join(' ') : clause[:phrase].to_s)
|
|
|
|
PhraseClause.new(operator, term)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
raise "Unexpected clause type: #{clause}"
|
|
|
|
raise "Unexpected clause type: #{clause}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|