mirror of
https://github.com/postgres/postgres.git
synced 2025-10-29 22:49:41 +03:00
Add websearch_to_tsquery
Error-tolerant conversion function with web-like syntax for search query, it simplifies constraining search engine with close to habitual interface for users. Bump catalog version Authors: Victor Drobny, Dmitry Ivanov with editorization by me Reviewed by: Aleksander Alekseev, Tomas Vondra, Thomas Munro, Aleksandr Parfenov Discussion: https://www.postgresql.org/message-id/flat/fe931111ff7e9ad79196486ada79e268@postgrespro.ru
This commit is contained in:
@@ -53,6 +53,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201804031
|
||||
#define CATALOG_VERSION_NO 201804051
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4971,6 +4971,8 @@ DATA(insert OID = 3747 ( plainto_tsquery PGNSP PGUID 12 100 0 0 0 f f f t f i s
|
||||
DESCR("transform to tsquery");
|
||||
DATA(insert OID = 5006 ( phraseto_tsquery PGNSP PGUID 12 100 0 0 0 f f f t f i s 2 0 3615 "3734 25" _null_ _null_ _null_ _null_ _null_ phraseto_tsquery_byid _null_ _null_ _null_ ));
|
||||
DESCR("transform to tsquery");
|
||||
DATA(insert OID = 8889 ( websearch_to_tsquery PGNSP PGUID 12 100 0 0 0 f f f t f i s 2 0 3615 "3734 25" _null_ _null_ _null_ _null_ _null_ websearch_to_tsquery_byid _null_ _null_ _null_ ));
|
||||
DESCR("transform to tsquery");
|
||||
DATA(insert OID = 3749 ( to_tsvector PGNSP PGUID 12 100 0 0 0 f f f t f s s 1 0 3614 "25" _null_ _null_ _null_ _null_ _null_ to_tsvector _null_ _null_ _null_ ));
|
||||
DESCR("transform to tsvector");
|
||||
DATA(insert OID = 3750 ( to_tsquery PGNSP PGUID 12 100 0 0 0 f f f t f s s 1 0 3615 "25" _null_ _null_ _null_ _null_ _null_ to_tsquery _null_ _null_ _null_ ));
|
||||
@@ -4979,6 +4981,8 @@ DATA(insert OID = 3751 ( plainto_tsquery PGNSP PGUID 12 100 0 0 0 f f f t f s s
|
||||
DESCR("transform to tsquery");
|
||||
DATA(insert OID = 5001 ( phraseto_tsquery PGNSP PGUID 12 100 0 0 0 f f f t f s s 1 0 3615 "25" _null_ _null_ _null_ _null_ _null_ phraseto_tsquery _null_ _null_ _null_ ));
|
||||
DESCR("transform to tsquery");
|
||||
DATA(insert OID = 8890 ( websearch_to_tsquery PGNSP PGUID 12 100 0 0 0 f f f t f s s 1 0 3615 "25" _null_ _null_ _null_ _null_ _null_ websearch_to_tsquery _null_ _null_ _null_ ));
|
||||
DESCR("transform to tsquery");
|
||||
DATA(insert OID = 4209 ( to_tsvector PGNSP PGUID 12 100 0 0 0 f f f t f s s 1 0 3614 "3802" _null_ _null_ _null_ _null_ _null_ jsonb_to_tsvector _null_ _null_ _null_ ));
|
||||
DESCR("transform jsonb to tsvector");
|
||||
DATA(insert OID = 4210 ( to_tsvector PGNSP PGUID 12 100 0 0 0 f f f t f s s 1 0 3614 "114" _null_ _null_ _null_ _null_ _null_ json_to_tsvector _null_ _null_ _null_ ));
|
||||
|
||||
@@ -25,9 +25,11 @@
|
||||
struct TSVectorParseStateData; /* opaque struct in tsvector_parser.c */
|
||||
typedef struct TSVectorParseStateData *TSVectorParseState;
|
||||
|
||||
extern TSVectorParseState init_tsvector_parser(char *input,
|
||||
bool oprisdelim,
|
||||
bool is_tsquery);
|
||||
#define P_TSV_OPR_IS_DELIM (1 << 0)
|
||||
#define P_TSV_IS_TSQUERY (1 << 1)
|
||||
#define P_TSV_IS_WEB (1 << 2)
|
||||
|
||||
extern TSVectorParseState init_tsvector_parser(char *input, int flags);
|
||||
extern void reset_tsvector_parser(TSVectorParseState state, char *input);
|
||||
extern bool gettoken_tsvector(TSVectorParseState state,
|
||||
char **token, int *len,
|
||||
@@ -35,6 +37,16 @@ extern bool gettoken_tsvector(TSVectorParseState state,
|
||||
char **endptr);
|
||||
extern void close_tsvector_parser(TSVectorParseState state);
|
||||
|
||||
/* phrase operator begins with '<' */
|
||||
#define ISOPERATOR(x) \
|
||||
( pg_mblen(x) == 1 && ( *(x) == '!' || \
|
||||
*(x) == '&' || \
|
||||
*(x) == '|' || \
|
||||
*(x) == '(' || \
|
||||
*(x) == ')' || \
|
||||
*(x) == '<' \
|
||||
) )
|
||||
|
||||
/* parse_tsquery */
|
||||
|
||||
struct TSQueryParserStateData; /* private in backend/utils/adt/tsquery.c */
|
||||
@@ -46,9 +58,13 @@ typedef void (*PushFunction) (Datum opaque, TSQueryParserState state,
|
||||
* QueryOperand struct */
|
||||
bool prefix);
|
||||
|
||||
#define P_TSQ_PLAIN (1 << 0)
|
||||
#define P_TSQ_WEB (1 << 1)
|
||||
|
||||
extern TSQuery parse_tsquery(char *buf,
|
||||
PushFunction pushval,
|
||||
Datum opaque, bool isplain);
|
||||
PushFunction pushval,
|
||||
Datum opaque,
|
||||
int flags);
|
||||
|
||||
/* Functions for use by PushFunction implementations */
|
||||
extern void pushValue(TSQueryParserState state,
|
||||
|
||||
Reference in New Issue
Block a user