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|bar" => "foo:*&bar:*"
16 // " oo|ba " => "oo:*&ba:*"
20 window.to_tsquery = function(q) {
21 q = (q || '').replace(/[^\w\.]+/g, ' ').trim().replace(/ /g, ':*&')