4523: update full text search to append ':*' for each word to support a collection...
authorRadhika Chippada <radhika@curoverse.com>
Sun, 8 Feb 2015 21:22:07 +0000 (16:22 -0500)
committerRadhika Chippada <radhika@curoverse.com>
Sun, 8 Feb 2015 21:22:07 +0000 (16:22 -0500)
services/api/lib/record_filters.rb

index 51153fe081267162139a3ec0dbadbe49bfd1b1eb..0b6510879692297cd3d69e0d8088e53c60c5c74a 100644 (file)
@@ -43,11 +43,9 @@ module RecordFilters
         end
         attrs = [] #  skip the generic per-column operator loop below
         # Use to_tsquery since plainto_tsquery does not support prefix search.
-        # Instead split operand and join the words with ' & ' and add ':*' to the last word
-        # Thus when searched for "some str", objects containing "some" and "str:*" are found.
+        # Instead split operand, add ':*' to each word and join the words with ' & '
         cond_out << model_class.full_text_tsvector+" @@ to_tsquery(?)"
-        operand << ':*'
-        param_out << operand.split.join(' & ')
+        param_out << operand.split.each {|s| s.concat(':*')}.join(' & ')
       else
        attrs.each do |attr|
         if !model_class.searchable_columns(operator).index attr.to_s