15106: Adds trigram search to the api
authorEric Biagiotti <ebiagiotti@veritasgenetics.com>
Mon, 10 Jun 2019 14:09:27 +0000 (10:09 -0400)
committerEric Biagiotti <ebiagiotti@veritasgenetics.com>
Mon, 10 Jun 2019 14:09:27 +0000 (10:09 -0400)
Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti@veritasgenetics.com>

services/api/lib/record_filters.rb

index 831e357b4235b6b11217de47ee2c5960a4ef3563..7b0d48b0518cc7365426915072fc7101a961bd03 100644 (file)
@@ -44,6 +44,14 @@ module RecordFilters
 
       cond_out = []
 
+      if attrs_in == 'any' && operator.casecmp('ilike') && operand.match('^[%].*[%]$')
+        # Trigram index search
+        cond_out << model_class.full_text_trgm + " ilike ?"
+        param_out << operand
+        # Skip the generic per-column operator loop below
+        attrs = []
+      end
+
       if operator == '@@'
         # Full-text search
         if attrs_in != 'any'