12462: Fix full-text search for terms like "foo.bar".
authorTom Clegg <tclegg@veritasgenetics.com>
Fri, 20 Oct 2017 17:59:45 +0000 (13:59 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Fri, 20 Oct 2017 17:59:45 +0000 (13:59 -0400)
A search for a filename like "foo.bar" should match text "foo.bar" --
but "foo.bar" was transformed to "foo:* & bar:*", and since "." is a
word character, "bar:*" did not match "foo.bar".

Now "foo.bar" is transformed to "foo.bar:*".

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

apps/workbench/app/assets/javascripts/to_tsquery.js

index ab584d4be6682088b2c5d396dc2d28fe21b40006..34ccb6c2774d26fe7e85e701a0672e6df5ebacf3 100644 (file)
 //
 // "foo"     => "foo:*"
 // "foo/bar" => "foo:*&bar:*"
+// "foo.bar" => "foo.bar:*"    // "." is a word char in FT queries
 // "foo|bar" => "foo:*&bar:*"
 // " oo|ba " => "oo:*&ba:*"
 // "// "     => null
 // ""        => null
 // null      => null
 window.to_tsquery = function(q) {
-    q = (q || '').replace(/\W+/g, ' ').trim().replace(/ /g, ':*&')
+    q = (q || '').replace(/[^\w\.]+/g, ' ').trim().replace(/ /g, ':*&')
     if (q == '')
         return null
     return q + ':*'