2012-06-20 13:58:24 |
Abel Deuring |
description |
from a full-text-search-indexed text is used in a
search, all texts containing this word should be returned by
a search.
This can fail if a word starts with a '~':
psql -d launchpad_dev
psql (9.1.4)
Type "help" for help.
launchpad_dev=# psql -d launchpad_dev
launchpad_dev-# ;
ERROR: syntax error at or near "psql"
LINE 1: psql -d launchpad_dev
^
launchpad_dev=# select to_tsvector('aaa ~bbb ccc') @@ to_tsquery('~bbb');
?column?
----------
f
The reason:
launchpad_dev=# select to_tsvector('aaa ~bbb ccc');
to_tsvector
-------------------------
'aaa':1 'bbb':2 'ccc':3
(1 row)
So, the '~' is stripped from '~bbb'. But the search term generated by
to_tsquery() retains the '~':
launchpad_dev=# select to_tsquery('~bbb');
to_tsquery
------------
'~bbb'
(1 row)
This is not completely wrong, because to_tsvector() sometimes keeps a
leading '~':
launchpad_dev=# select to_tsvector('~aaa bbb~ccc');
to_tsvector
---------------------------
'bbb':2 '~aaa':1 '~ccc':3
(1 row)
ts_debug() gives a clue what is happening:
launchpad_dev=# select ts_debug('~bbb');
ts_debug
--------------------------------------------------------
(file,"File or path name",~bbb,{simple},simple,{~bbb})
(1 row)
launchpad_dev=# select ts_debug('~aaa bbb~ccc');
ts_debug
---------------------------------------------------------------------
(file,"File or path name",~aaa,{simple},simple,{~aaa})
(blank,"Space symbols"," ",{},,)
(asciiword,"Word, all ASCII",bbb,{english_stem},english_stem,{bbb})
(file,"File or path name",~ccc,{simple},simple,{~ccc})
(4 rows)
So, a '~' at the start of a text or following a word is treated as the
first character of a filename, while a '~' preceded by a space is
simply dropped and the following word is treated as an oridnary word. |
from a full-text-search-indexed text is used in a
search, all texts containing this word should be returned by
a search.
This can fail if a word starts with a '~':
psql -d launchpad_dev
psql (9.1.4)
Type "help" for help.
launchpad_dev=# select to_tsvector('aaa ~bbb ccc') @@ to_tsquery('~bbb');
?column?
----------
f
The reason:
launchpad_dev=# select to_tsvector('aaa ~bbb ccc');
to_tsvector
-------------------------
'aaa':1 'bbb':2 'ccc':3
(1 row)
So, the '~' is stripped from '~bbb'. But the search term generated by
to_tsquery() retains the '~':
launchpad_dev=# select to_tsquery('~bbb');
to_tsquery
------------
'~bbb'
(1 row)
This is not completely wrong, because to_tsvector() sometimes keeps a
leading '~':
launchpad_dev=# select to_tsvector('~aaa bbb~ccc');
to_tsvector
---------------------------
'bbb':2 '~aaa':1 '~ccc':3
(1 row)
ts_debug() gives a clue what is happening:
launchpad_dev=# select ts_debug('~bbb');
ts_debug
--------------------------------------------------------
(file,"File or path name",~bbb,{simple},simple,{~bbb})
(1 row)
launchpad_dev=# select ts_debug('~aaa bbb~ccc');
ts_debug
---------------------------------------------------------------------
(file,"File or path name",~aaa,{simple},simple,{~aaa})
(blank,"Space symbols"," ",{},,)
(asciiword,"Word, all ASCII",bbb,{english_stem},english_stem,{bbb})
(file,"File or path name",~ccc,{simple},simple,{~ccc})
(4 rows)
So, a '~' at the start of a text or following a word is treated as the
first character of a filename, while a '~' preceded by a space is
simply dropped and the following word is treated as an oridnary word. |
|
2012-06-20 15:00:58 |
Abel Deuring |
description |
from a full-text-search-indexed text is used in a
search, all texts containing this word should be returned by
a search.
This can fail if a word starts with a '~':
psql -d launchpad_dev
psql (9.1.4)
Type "help" for help.
launchpad_dev=# select to_tsvector('aaa ~bbb ccc') @@ to_tsquery('~bbb');
?column?
----------
f
The reason:
launchpad_dev=# select to_tsvector('aaa ~bbb ccc');
to_tsvector
-------------------------
'aaa':1 'bbb':2 'ccc':3
(1 row)
So, the '~' is stripped from '~bbb'. But the search term generated by
to_tsquery() retains the '~':
launchpad_dev=# select to_tsquery('~bbb');
to_tsquery
------------
'~bbb'
(1 row)
This is not completely wrong, because to_tsvector() sometimes keeps a
leading '~':
launchpad_dev=# select to_tsvector('~aaa bbb~ccc');
to_tsvector
---------------------------
'bbb':2 '~aaa':1 '~ccc':3
(1 row)
ts_debug() gives a clue what is happening:
launchpad_dev=# select ts_debug('~bbb');
ts_debug
--------------------------------------------------------
(file,"File or path name",~bbb,{simple},simple,{~bbb})
(1 row)
launchpad_dev=# select ts_debug('~aaa bbb~ccc');
ts_debug
---------------------------------------------------------------------
(file,"File or path name",~aaa,{simple},simple,{~aaa})
(blank,"Space symbols"," ",{},,)
(asciiword,"Word, all ASCII",bbb,{english_stem},english_stem,{bbb})
(file,"File or path name",~ccc,{simple},simple,{~ccc})
(4 rows)
So, a '~' at the start of a text or following a word is treated as the
first character of a filename, while a '~' preceded by a space is
simply dropped and the following word is treated as an oridnary word. |
If a word from a full-text-search-indexed text is used in a
search, all texts containing this word should be returned by
this search.
This can fail if a word starts with a '~':
psql -d launchpad_dev
psql (9.1.4)
Type "help" for help.
launchpad_dev=# select to_tsvector('aaa ~bbb ccc') @@ to_tsquery('~bbb');
?column?
----------
f
The reason:
launchpad_dev=# select to_tsvector('aaa ~bbb ccc');
to_tsvector
-------------------------
'aaa':1 'bbb':2 'ccc':3
(1 row)
So, the '~' is stripped from '~bbb'. But the search term generated by
to_tsquery() retains the '~':
launchpad_dev=# select to_tsquery('~bbb');
to_tsquery
------------
'~bbb'
(1 row)
This is not completely wrong, because to_tsvector() sometimes keeps a
leading '~':
launchpad_dev=# select to_tsvector('~aaa bbb~ccc');
to_tsvector
---------------------------
'bbb':2 '~aaa':1 '~ccc':3
(1 row)
ts_debug() gives a clue what is happening:
launchpad_dev=# select ts_debug('~bbb');
ts_debug
--------------------------------------------------------
(file,"File or path name",~bbb,{simple},simple,{~bbb})
(1 row)
launchpad_dev=# select ts_debug('~aaa bbb~ccc');
ts_debug
---------------------------------------------------------------------
(file,"File or path name",~aaa,{simple},simple,{~aaa})
(blank,"Space symbols"," ",{},,)
(asciiword,"Word, all ASCII",bbb,{english_stem},english_stem,{bbb})
(file,"File or path name",~ccc,{simple},simple,{~ccc})
(4 rows)
So, a '~' at the start of a text or following a word is treated as the
first character of a filename, while a '~' preceded by a space is
simply dropped and the following word is treated as an oridnary word. |
|