I was playing with tsquery and found that I can use *
alone, (not as in foo:*), and it is accepted, but I have no idea of the behavior of this operator or if it is safe to use it
Here is an example
SELECT *, ts_rank_cd(x, query) AS rank
FROM to_tsquery('cat & *') query,
(VALUES
(to_tsvector('cat say meow')),
(to_tsvector('dog say woof'))) as t(x)
WHERE query @@ t.x
Here is a dbfidle with it https://www.db-fiddle.com/f/4jyoMCicNSZpjMt4jFYoz5/9036
It returns
| query | x | rank |
| ----- | ------------------------ | ---- |
| 'cat' | 'cat':1 'meow':3 'say':2 | 0.1 |
If I try it alone like to_tsquery('*')
, it returns 0 rows. Does anybody know the behavior of this operator, or if is documented anywhere?
The documentation pages I checked were these:
Update
I think it is recognized as a punctuation, because ?
or .
works in the same way, the pertinent question is what punctuation matches?
The *
is ignored:
SELECT to_tsquery('cat & *');
to_tsquery
════════════
'cat'
(1 row)
So it is safe to use, but pointless.
*
is nothing special here: the same happens with all characters that are not letters. They are simply ignored in full-text search.