1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 // to_tsquery_filters() converts a user-entered search query to a list of
6 // filters using the newly added (as for arvados 1.5) trigram indexes. It returns
7 // null if it can't come up with anything valid (e.g., q consists entirely of
12 // "foo" => [["any", "ilike", "%foo%"]]
13 // "foo.bar" => [["any", "ilike", "%foo.bar%"]] // "." is a word char in FT queries
14 // "foo/b-r" => [["any", "ilike", "%foo/b-r%"]] // "/" and "-", too
15 // "foo bar" => [["any", "ilike", "%foo%"], ["any", "ilike", "%bar%"]]
16 // "foo|bar" => [["any", "ilike", "%foo%"], ["any", "ilike", "%bar%"]]
17 // " oo|bar" => [["any", "ilike", "%oo%"], ["any", "ilike", "%bar%"]]
21 window.to_tsquery_filters = function(q) {
22 q = (q || '').replace(/[^-\w\.\/]+/g, ' ').trim()
25 return q.split(" ").map(function(term) {
26 return ["any", "ilike", "%"+term+"%"]