15429: Removes unused to_tsquery()
[arvados.git] / apps / workbench / app / assets / javascripts / to_tsquery.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
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
8 // punctuation).
9 //
10 // Examples:
11 //
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%"]]
18 // ""        => []
19 // " "       => []
20 // null      => []
21 window.to_tsquery_filters = function(q) {
22     q = (q || '').replace(/[^-\w\.\/]+/g, ' ').trim()
23     if (q == '')
24         return []
25     return q.split(" ").map(function(term) {
26         return ["any", "ilike", "%"+term+"%"]
27     })
28 }