15106: Changes full text search to use trigram indexing
[arvados-workbench2.git] / src / services / api / filter-builder.ts
index e8992341098eb4b9ee506aa529a9a72a06b948fa..77fcef6fca096bf8a13a406f1b3e0b1bd1a8ed25 100644 (file)
@@ -56,10 +56,13 @@ export class FilterBuilder {
     }
 
     public addFullTextSearch(value: string) {
-        // Filter construction implementation taken from 
-        // https://dev.arvados.org/projects/arvados/repository/entry/apps/workbench/app/assets/javascripts/filterable.js
-        // https://dev.arvados.org/projects/arvados/repository/entry/apps/workbench/app/assets/javascripts/to_tsquery.js
-        return this.addCondition('any', '@@', value.replace(/[^-\w\.\/]+/g, ' ').trim().replace(/ /g, ':*&'));
+        const terms = value.trim().split(/(\s+)/);
+        terms.forEach(term => {
+            if (term !== " ") {
+                this.addCondition("any", "ilike", term, "%", "%");
+            }
+        });
+        return this;
     }
 
     public getFilters() {