[ARVADOS] created: 1.3.0-1747-g9f5256256

Git user git at public.curoverse.com
Tue Oct 15 20:20:54 UTC 2019


        at  9f5256256f4b29188aa441f2e506297d27e200ce (commit)


commit 9f5256256f4b29188aa441f2e506297d27e200ce
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Tue Oct 15 17:18:27 2019 -0300

    15429: Changes full text searching on wb1 utilizing new trigram indexes.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/apps/workbench/app/assets/javascripts/components/search.js b/apps/workbench/app/assets/javascripts/components/search.js
index 04572ec3c..6af2dcacc 100644
--- a/apps/workbench/app/assets/javascripts/components/search.js
+++ b/apps/workbench/app/assets/javascripts/components/search.js
@@ -143,10 +143,9 @@ window.Search = {
                                 loadFunc: function(filters) {
                                     // Apply additional type dependant filters
                                     filters = filters.concat(obj_type.filters)
-                                    var tsquery = to_tsquery(q)
-                                    if (tsquery) {
-                                        filters.push(['any', '@@', tsquery])
-                                    }
+                                    to_tsquery_filters(q).forEach(function(f) {
+                                        filters.push(f)
+                                    })
                                     return vnode.state.sessionDB.request(session, obj_type.api_path, {
                                         data: {
                                             filters: JSON.stringify(filters),
diff --git a/apps/workbench/app/assets/javascripts/filterable.js b/apps/workbench/app/assets/javascripts/filterable.js
index e571e32db..768ff52d9 100644
--- a/apps/workbench/app/assets/javascripts/filterable.js
+++ b/apps/workbench/app/assets/javascripts/filterable.js
@@ -61,12 +61,7 @@
 function updateFilterableQueryNow($target) {
     var newquery = $target.data('filterable-query-new');
     var params = $target.data('infinite-content-params-filterable') || {};
-    var tsquery = to_tsquery(newquery);
-    if (tsquery == null) {
-        params.filters = [];
-    } else {
-        params.filters = [['any', '@@', tsquery]];
-    }
+    params.filters = to_tsquery_filters(newquery);
     $(".modal-dialog-preview-pane").html("");
     $target.data('infinite-content-params-filterable', params);
     $target.data('filterable-query', newquery);
diff --git a/apps/workbench/app/assets/javascripts/to_tsquery.js b/apps/workbench/app/assets/javascripts/to_tsquery.js
index f2e34d9e0..dbb17f3f7 100644
--- a/apps/workbench/app/assets/javascripts/to_tsquery.js
+++ b/apps/workbench/app/assets/javascripts/to_tsquery.js
@@ -24,3 +24,23 @@ window.to_tsquery = function(q) {
         return null
     return q + ':*'
 }
+
+// to_tsquery_filters() converts a user-entered search query to a list of
+// filters using the newly added (as for arvados 1.5) trigram indexes.
+//
+// Examples:
+//
+// "foo"     => [["any", "ilike", "%foo%"]]
+// "foo.bar" => [["any", "ilike", "%foo.bar%"]]
+// "foo bar" => [["any", "ilike", "%foo%"], ["any", "ilike", "%bar%"]]
+// "foo|bar" => [["any", "ilike", "%foo%"], ["any", "ilike", "%bar%"]]
+// ""        => []
+// null      => []
+window.to_tsquery_filters = function(q) {
+    q = (q || '').replace(/[^-\w\.\/]+/g, ' ').trim()
+    if (q == '')
+        return []
+    return q.split(" ").map(function(term) {
+        return ["any", "ilike", "%"+term+"%"]
+    })
+}
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list