1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 // to_tsquery() converts a user-entered search query to a useful
6 // operand for the Arvados API "@@" filter. It returns null if it
7 // can't come up with anything valid (e.g., q consists entirely of
13 // "foo_bar" => "foo:*&bar:*"
14 // "foo.bar" => "foo.bar:*" // "." is a word char in FT queries
15 // "foo/b-r" => "foo/b-r:*" // "/" and "-", too
16 // "foo|bar" => "foo:*&bar:*"
17 // " oo|ba " => "oo:*&ba:*"
21 window.to_tsquery = function(q) {
22 q = (q || '').replace(/[^-\w\.\/]+/g, ' ').trim().replace(/ /g, ':*&')