Create addFullTextSearch of FilterBuilder
[arvados-workbench2.git] / src / services / api / filter-builder.ts
index 4b3db9fa2b92bb976a577a7e0eb2ee8de4161ab5..e8992341098eb4b9ee506aa529a9a72a06b948fa 100644 (file)
@@ -55,6 +55,13 @@ export class FilterBuilder {
         return this.addCondition("properties", "exists", value, "", "", resourcePrefix);
     }
 
+    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, ':*&'));
+    }
+
     public getFilters() {
         return this.filters;
     }