X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8cd7249b96576285388ef036d04532f72a8f1ee3..1128f6e0d62f71f4ee91ab609c918ae5bb291edd:/services/api/lib/record_filters.rb diff --git a/services/api/lib/record_filters.rb b/services/api/lib/record_filters.rb index b8cdef0b73..c009bf537f 100644 --- a/services/api/lib/record_filters.rb +++ b/services/api/lib/record_filters.rb @@ -37,15 +37,23 @@ module RecordFilters cond_out = [] - if operator == '@@' # full-text-search + if operator == '@@' + # Full-text search if attrs_in != 'any' raise ArgumentError.new("Full text search on individual columns is not supported") end - attrs = [] # skip the generic per-column operator loop below + if operand.is_a? Array + raise ArgumentError.new("Full text search not supported for array operands") + end + + # Skip the generic per-column operator loop below + attrs = [] + # Use to_tsquery since plainto_tsquery does not support prefix + # search. And, split operand and join the words with ' & ' cond_out << model_class.full_text_tsvector+" @@ to_tsquery(?)" - param_out << operand.split.each {|s| s.concat(':*')}.join(' & ') - else - attrs.each do |attr| + param_out << operand.split.join(' & ') + end + attrs.each do |attr| if !model_class.searchable_columns(operator).index attr.to_s raise ArgumentError.new("Invalid attribute '#{attr}' in filter") end @@ -114,7 +122,6 @@ module RecordFilters end cond_out << cond.join(' OR ') end - end end conds_out << cond_out.join(' OR ') if cond_out.any? end