mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-02 03:51:15 +02:00
Remove the aggregate form of ts_rewrite(), since it doesn't work as desired
if there are zero rows to aggregate over, and the API seems both conceptually and notationally ugly anyway. We should look for something that improves on the tsquery-and-text-SELECT version (which is also pretty ugly but at least it works...), but it seems that will take query infrastructure that doesn't exist today. (Hm, I wonder if there's anything in or near SQL2003 window functions that would help?) Per discussion.
This commit is contained in:
parent
07d0a370c1
commit
592c88a0d2
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.24 2007/10/23 20:46:12 tgl Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.25 2007/10/24 02:24:47 tgl Exp $ -->
|
||||||
|
|
||||||
<chapter id="textsearch">
|
<chapter id="textsearch">
|
||||||
<title id="textsearch-title">Full Text Search</title>
|
<title id="textsearch-title">Full Text Search</title>
|
||||||
@ -1456,33 +1456,6 @@ SELECT ts_rewrite('a & b'::tsquery, 'a'::tsquery, 'c'::tsquery);
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
|
|
||||||
<term>
|
|
||||||
<synopsis>
|
|
||||||
ts_rewrite(ARRAY[<replaceable class="PARAMETER">query</replaceable> <type>tsquery</>, <replaceable class="PARAMETER">target</replaceable> <type>tsquery</>, <replaceable class="PARAMETER">substitute</replaceable> <type>tsquery</>]) returns <type>tsquery</>
|
|
||||||
</synopsis>
|
|
||||||
</term>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Aggregate form. XXX if we choose not to remove this, it needs to
|
|
||||||
be documented better. Note it is not listed in
|
|
||||||
textsearch-functions-table at the moment.
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
CREATE TABLE aliases (t tsquery PRIMARY KEY, s tsquery);
|
|
||||||
INSERT INTO aliases VALUES('a', 'c');
|
|
||||||
|
|
||||||
SELECT ts_rewrite(ARRAY['a & b'::tsquery, t,s]) FROM aliases;
|
|
||||||
ts_rewrite
|
|
||||||
------------
|
|
||||||
'b' & 'c'
|
|
||||||
</programlisting>
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
||||||
<term>
|
<term>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.5 2007/10/23 01:44:39 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.6 2007/10/24 02:24:47 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -250,135 +250,7 @@ findsubquery(QTNode *root, QTNode *ex, QTNode *subs, bool *isfind)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
ts_rewrite_accum(PG_FUNCTION_ARGS)
|
tsquery_rewrite_query(PG_FUNCTION_ARGS)
|
||||||
{
|
|
||||||
TSQuery acc;
|
|
||||||
ArrayType *qa;
|
|
||||||
TSQuery q;
|
|
||||||
QTNode *qex = NULL,
|
|
||||||
*subs = NULL,
|
|
||||||
*acctree = NULL;
|
|
||||||
bool isfind = false;
|
|
||||||
Datum *elemsp;
|
|
||||||
int nelemsp;
|
|
||||||
MemoryContext aggcontext;
|
|
||||||
MemoryContext oldcontext;
|
|
||||||
|
|
||||||
aggcontext = ((AggState *) fcinfo->context)->aggcontext;
|
|
||||||
|
|
||||||
if (PG_ARGISNULL(0) || PG_GETARG_POINTER(0) == NULL)
|
|
||||||
{
|
|
||||||
acc = (TSQuery) MemoryContextAlloc(aggcontext, HDRSIZETQ);
|
|
||||||
SET_VARSIZE(acc, HDRSIZETQ);
|
|
||||||
acc->size = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
acc = PG_GETARG_TSQUERY(0);
|
|
||||||
|
|
||||||
if (PG_ARGISNULL(1) || PG_GETARG_POINTER(1) == NULL)
|
|
||||||
PG_RETURN_TSQUERY(acc);
|
|
||||||
else
|
|
||||||
qa = PG_GETARG_ARRAYTYPE_P_COPY(1);
|
|
||||||
|
|
||||||
if (ARR_NDIM(qa) != 1)
|
|
||||||
elog(ERROR, "array must be one-dimensional, not %d dimensions",
|
|
||||||
ARR_NDIM(qa));
|
|
||||||
if (ArrayGetNItems(ARR_NDIM(qa), ARR_DIMS(qa)) != 3)
|
|
||||||
elog(ERROR, "array must have three elements");
|
|
||||||
if (ARR_ELEMTYPE(qa) != TSQUERYOID)
|
|
||||||
elog(ERROR, "array must contain tsquery elements");
|
|
||||||
|
|
||||||
deconstruct_array(qa, TSQUERYOID, -1, false, 'i', &elemsp, NULL, &nelemsp);
|
|
||||||
|
|
||||||
q = DatumGetTSQuery(elemsp[0]);
|
|
||||||
if (q->size == 0)
|
|
||||||
{
|
|
||||||
pfree(elemsp);
|
|
||||||
PG_RETURN_POINTER(acc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!acc->size)
|
|
||||||
{
|
|
||||||
if (VARSIZE(acc) > HDRSIZETQ)
|
|
||||||
{
|
|
||||||
pfree(elemsp);
|
|
||||||
PG_RETURN_POINTER(acc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
acctree = QT2QTN(GETQUERY(q), GETOPERAND(q));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
acctree = QT2QTN(GETQUERY(acc), GETOPERAND(acc));
|
|
||||||
|
|
||||||
QTNTernary(acctree);
|
|
||||||
QTNSort(acctree);
|
|
||||||
|
|
||||||
q = DatumGetTSQuery(elemsp[1]);
|
|
||||||
if (q->size == 0)
|
|
||||||
{
|
|
||||||
pfree(elemsp);
|
|
||||||
PG_RETURN_POINTER(acc);
|
|
||||||
}
|
|
||||||
qex = QT2QTN(GETQUERY(q), GETOPERAND(q));
|
|
||||||
QTNTernary(qex);
|
|
||||||
QTNSort(qex);
|
|
||||||
|
|
||||||
q = DatumGetTSQuery(elemsp[2]);
|
|
||||||
if (q->size)
|
|
||||||
subs = QT2QTN(GETQUERY(q), GETOPERAND(q));
|
|
||||||
|
|
||||||
acctree = findsubquery(acctree, qex, subs, &isfind);
|
|
||||||
|
|
||||||
if (isfind || !acc->size)
|
|
||||||
{
|
|
||||||
/* pfree( acc ); do not pfree(p), because nodeAgg.c will */
|
|
||||||
if (acctree)
|
|
||||||
{
|
|
||||||
QTNBinary(acctree);
|
|
||||||
oldcontext = MemoryContextSwitchTo(aggcontext);
|
|
||||||
acc = QTN2QT(acctree);
|
|
||||||
MemoryContextSwitchTo(oldcontext);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
acc = (TSQuery) MemoryContextAlloc(aggcontext, HDRSIZETQ);
|
|
||||||
SET_VARSIZE(acc, HDRSIZETQ);
|
|
||||||
acc->size = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pfree(elemsp);
|
|
||||||
QTNFree(qex);
|
|
||||||
QTNFree(subs);
|
|
||||||
QTNFree(acctree);
|
|
||||||
|
|
||||||
PG_RETURN_TSQUERY(acc);
|
|
||||||
}
|
|
||||||
|
|
||||||
Datum
|
|
||||||
ts_rewrite_finish(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
TSQuery acc = PG_GETARG_TSQUERY(0);
|
|
||||||
TSQuery rewrited;
|
|
||||||
|
|
||||||
if (acc == NULL || PG_ARGISNULL(0) || acc->size == 0)
|
|
||||||
{
|
|
||||||
rewrited = (TSQuery) palloc(HDRSIZETQ);
|
|
||||||
SET_VARSIZE(rewrited, HDRSIZETQ);
|
|
||||||
rewrited->size = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rewrited = (TSQuery) palloc(VARSIZE(acc));
|
|
||||||
memcpy(rewrited, acc, VARSIZE(acc));
|
|
||||||
pfree(acc);
|
|
||||||
}
|
|
||||||
|
|
||||||
PG_RETURN_POINTER(rewrited);
|
|
||||||
}
|
|
||||||
|
|
||||||
Datum
|
|
||||||
tsquery_rewrite(PG_FUNCTION_ARGS)
|
|
||||||
{
|
{
|
||||||
TSQuery query = PG_GETARG_TSQUERY_COPY(0);
|
TSQuery query = PG_GETARG_TSQUERY_COPY(0);
|
||||||
text *in = PG_GETARG_TEXT_P(1);
|
text *in = PG_GETARG_TEXT_P(1);
|
||||||
@ -505,7 +377,7 @@ tsquery_rewrite(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
tsquery_rewrite_query(PG_FUNCTION_ARGS)
|
tsquery_rewrite(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
TSQuery query = PG_GETARG_TSQUERY_COPY(0);
|
TSQuery query = PG_GETARG_TSQUERY_COPY(0);
|
||||||
TSQuery ex = PG_GETARG_TSQUERY(1);
|
TSQuery ex = PG_GETARG_TSQUERY(1);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.436 2007/10/23 20:46:12 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.437 2007/10/24 02:24:47 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -53,6 +53,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* yyyymmddN */
|
/* yyyymmddN */
|
||||||
#define CATALOG_VERSION_NO 200710231
|
#define CATALOG_VERSION_NO 200710232
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.63 2007/08/21 01:11:25 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.64 2007/10/24 02:24:47 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* the genbki.sh script reads this file and generates .bki
|
* the genbki.sh script reads this file and generates .bki
|
||||||
@ -226,9 +226,6 @@ DATA(insert ( 2243 bitor - 0 1560 _null_ ));
|
|||||||
/* xml */
|
/* xml */
|
||||||
DATA(insert ( 2901 xmlconcat2 - 0 142 _null_ ));
|
DATA(insert ( 2901 xmlconcat2 - 0 142 _null_ ));
|
||||||
|
|
||||||
/* text search */
|
|
||||||
DATA(insert ( 3688 ts_rewrite_accum ts_rewrite_finish 0 3615 _null_ ));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* prototypes for functions in pg_aggregate.c
|
* prototypes for functions in pg_aggregate.c
|
||||||
*/
|
*/
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.476 2007/10/19 22:01:45 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.477 2007/10/24 02:24:47 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* The script catalog/genbki.sh reads this file and generates .bki
|
* The script catalog/genbki.sh reads this file and generates .bki
|
||||||
@ -4258,15 +4258,9 @@ DESCR("number of nodes");
|
|||||||
DATA(insert OID = 3673 ( querytree PGNSP PGUID 12 1 0 f f t f i 1 25 "3615" _null_ _null_ _null_ tsquerytree - _null_ _null_ ));
|
DATA(insert OID = 3673 ( querytree PGNSP PGUID 12 1 0 f f t f i 1 25 "3615" _null_ _null_ _null_ tsquerytree - _null_ _null_ ));
|
||||||
DESCR("show real useful query for GiST index");
|
DESCR("show real useful query for GiST index");
|
||||||
|
|
||||||
DATA(insert OID = 3684 ( ts_rewrite PGNSP PGUID 12 1 0 f f t f i 3 3615 "3615 3615 3615" _null_ _null_ _null_ tsquery_rewrite_query - _null_ _null_ ));
|
DATA(insert OID = 3684 ( ts_rewrite PGNSP PGUID 12 1 0 f f t f i 3 3615 "3615 3615 3615" _null_ _null_ _null_ tsquery_rewrite - _null_ _null_ ));
|
||||||
DESCR("rewrite tsquery");
|
DESCR("rewrite tsquery");
|
||||||
DATA(insert OID = 3685 ( ts_rewrite PGNSP PGUID 12 1 0 f f t f v 2 3615 "3615 25" _null_ _null_ _null_ tsquery_rewrite - _null_ _null_ ));
|
DATA(insert OID = 3685 ( ts_rewrite PGNSP PGUID 12 1 0 f f t f v 2 3615 "3615 25" _null_ _null_ _null_ tsquery_rewrite_query - _null_ _null_ ));
|
||||||
DESCR("rewrite tsquery");
|
|
||||||
DATA(insert OID = 3686 ( ts_rewrite_accum PGNSP PGUID 12 1 0 f f f f i 2 3615 "3615 3645" _null_ _null_ _null_ ts_rewrite_accum - _null_ _null_ ));
|
|
||||||
DESCR("rewrite tsquery accumulator");
|
|
||||||
DATA(insert OID = 3687 ( ts_rewrite_finish PGNSP PGUID 12 1 0 f f t f i 1 3615 "3615" _null_ _null_ _null_ ts_rewrite_finish - _null_ _null_ ));
|
|
||||||
DESCR("rewrite tsquery finish");
|
|
||||||
DATA(insert OID = 3688 ( ts_rewrite PGNSP PGUID 12 1 0 t f f f i 1 3615 "3645" _null_ _null_ _null_ aggregate_dummy - _null_ _null_ ));
|
|
||||||
DESCR("rewrite tsquery");
|
DESCR("rewrite tsquery");
|
||||||
|
|
||||||
DATA(insert OID = 3695 ( gtsquery_compress PGNSP PGUID 12 1 0 f f t f i 1 2281 "2281" _null_ _null_ _null_ gtsquery_compress - _null_ _null_ ));
|
DATA(insert OID = 3695 ( gtsquery_compress PGNSP PGUID 12 1 0 f f t f i 1 2281 "2281" _null_ _null_ _null_ gtsquery_compress - _null_ _null_ ));
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1998-2007, PostgreSQL Global Development Group
|
* Copyright (c) 1998-2007, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/tsearch/ts_type.h,v 1.6 2007/09/11 16:01:40 teodor Exp $
|
* $PostgreSQL: pgsql/src/include/tsearch/ts_type.h,v 1.7 2007/10/24 02:24:49 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -285,8 +285,6 @@ extern Datum tsquery_not(PG_FUNCTION_ARGS);
|
|||||||
|
|
||||||
extern Datum tsquery_rewrite(PG_FUNCTION_ARGS);
|
extern Datum tsquery_rewrite(PG_FUNCTION_ARGS);
|
||||||
extern Datum tsquery_rewrite_query(PG_FUNCTION_ARGS);
|
extern Datum tsquery_rewrite_query(PG_FUNCTION_ARGS);
|
||||||
extern Datum ts_rewrite_accum(PG_FUNCTION_ARGS);
|
|
||||||
extern Datum ts_rewrite_finish(PG_FUNCTION_ARGS);
|
|
||||||
|
|
||||||
extern Datum tsq_mcontains(PG_FUNCTION_ARGS);
|
extern Datum tsq_mcontains(PG_FUNCTION_ARGS);
|
||||||
extern Datum tsq_mcontained(PG_FUNCTION_ARGS);
|
extern Datum tsq_mcontained(PG_FUNCTION_ARGS);
|
||||||
|
@ -676,25 +676,25 @@ SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::
|
|||||||
'hotel' & ( 'moskva' | 'moscow' )
|
'hotel' & ( 'moskva' | 'moscow' )
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite('bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery'::text );
|
SELECT ts_rewrite('bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery'::text );
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------
|
||||||
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY['moscow', keyword, sample] ) FROM test_tsquery;
|
SELECT ts_rewrite( 'moscow', 'SELECT keyword, sample FROM test_tsquery');
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
---------------------
|
---------------------
|
||||||
'moskva' | 'moscow'
|
'moskva' | 'moscow'
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY['moscow & hotel', keyword, sample] ) FROM test_tsquery;
|
SELECT ts_rewrite( 'moscow & hotel', 'SELECT keyword, sample FROM test_tsquery');
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
( 'moskva' | 'moscow' ) & 'hotel'
|
'hotel' & ( 'moskva' | 'moscow' )
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY['bar & new & qq & foo & york', keyword, sample] ) FROM test_tsquery;
|
SELECT ts_rewrite( 'bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery');
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------
|
||||||
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
||||||
@ -723,37 +723,37 @@ SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
|
|||||||
'moscow'
|
'moscow'
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
---------------------
|
---------------------
|
||||||
'moskva' | 'moscow'
|
'moskva' | 'moscow'
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
( 'moskva' | 'moscow' ) & 'hotel'
|
'hotel' & ( 'moskva' | 'moscow' )
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------
|
||||||
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
---------------------
|
---------------------
|
||||||
'moskva' | 'moscow'
|
'moskva' | 'moscow'
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
( 'moskva' | 'moscow' ) & 'hotel'
|
'hotel' & ( 'moskva' | 'moscow' )
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------
|
||||||
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
||||||
@ -784,37 +784,37 @@ SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
|
|||||||
'moscow'
|
'moscow'
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
---------------------
|
---------------------
|
||||||
'moskva' | 'moscow'
|
'moskva' | 'moscow'
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
( 'moskva' | 'moscow' ) & 'hotel'
|
'hotel' & ( 'moskva' | 'moscow' )
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------
|
||||||
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
---------------------
|
---------------------
|
||||||
'moskva' | 'moscow'
|
'moskva' | 'moscow'
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
( 'moskva' | 'moscow' ) & 'hotel'
|
'hotel' & ( 'moskva' | 'moscow' )
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
-------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------
|
||||||
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
|
||||||
|
@ -229,23 +229,23 @@ SELECT ts_rewrite('foo & bar & qq & new & york', 'new & york'::tsquery, 'big &
|
|||||||
|
|
||||||
SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text );
|
SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text );
|
||||||
SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text );
|
SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text );
|
||||||
SELECT ts_rewrite('bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery'::text );
|
SELECT ts_rewrite('bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery'::text );
|
||||||
|
|
||||||
SELECT ts_rewrite( ARRAY['moscow', keyword, sample] ) FROM test_tsquery;
|
SELECT ts_rewrite( 'moscow', 'SELECT keyword, sample FROM test_tsquery');
|
||||||
SELECT ts_rewrite( ARRAY['moscow & hotel', keyword, sample] ) FROM test_tsquery;
|
SELECT ts_rewrite( 'moscow & hotel', 'SELECT keyword, sample FROM test_tsquery');
|
||||||
SELECT ts_rewrite( ARRAY['bar & new & qq & foo & york', keyword, sample] ) FROM test_tsquery;
|
SELECT ts_rewrite( 'bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery');
|
||||||
|
|
||||||
|
|
||||||
SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
|
SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
|
||||||
SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
|
SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
|
||||||
SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
|
SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
|
||||||
SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
|
SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
|
||||||
|
|
||||||
CREATE INDEX qq ON test_tsquery USING gist (keyword tsquery_ops);
|
CREATE INDEX qq ON test_tsquery USING gist (keyword tsquery_ops);
|
||||||
SET enable_seqscan=OFF;
|
SET enable_seqscan=OFF;
|
||||||
@ -254,12 +254,12 @@ SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
|
|||||||
SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
|
SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
|
||||||
SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
|
SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
|
||||||
SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
|
SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE keyword <@ query;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
|
||||||
SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE query @> keyword;
|
SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
|
||||||
|
|
||||||
RESET enable_seqscan;
|
RESET enable_seqscan;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user