mirror of
https://github.com/postgres/postgres.git
synced 2025-08-22 21:53:06 +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:
@@ -490,7 +490,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
|
||||
query = parse_tsquery(text_to_cstring(in),
|
||||
pushval_morph,
|
||||
PointerGetDatum(&data),
|
||||
false);
|
||||
0);
|
||||
|
||||
PG_RETURN_TSQUERY(query);
|
||||
}
|
||||
@@ -520,7 +520,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
|
||||
query = parse_tsquery(text_to_cstring(in),
|
||||
pushval_morph,
|
||||
PointerGetDatum(&data),
|
||||
true);
|
||||
P_TSQ_PLAIN);
|
||||
|
||||
PG_RETURN_POINTER(query);
|
||||
}
|
||||
@@ -551,7 +551,7 @@ phraseto_tsquery_byid(PG_FUNCTION_ARGS)
|
||||
query = parse_tsquery(text_to_cstring(in),
|
||||
pushval_morph,
|
||||
PointerGetDatum(&data),
|
||||
true);
|
||||
P_TSQ_PLAIN);
|
||||
|
||||
PG_RETURN_TSQUERY(query);
|
||||
}
|
||||
@@ -567,3 +567,35 @@ phraseto_tsquery(PG_FUNCTION_ARGS)
|
||||
ObjectIdGetDatum(cfgId),
|
||||
PointerGetDatum(in)));
|
||||
}
|
||||
|
||||
Datum
|
||||
websearch_to_tsquery_byid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *in = PG_GETARG_TEXT_PP(1);
|
||||
MorphOpaque data;
|
||||
TSQuery query = NULL;
|
||||
|
||||
data.cfg_id = PG_GETARG_OID(0);
|
||||
|
||||
data.qoperator = OP_AND;
|
||||
|
||||
query = parse_tsquery(text_to_cstring(in),
|
||||
pushval_morph,
|
||||
PointerGetDatum(&data),
|
||||
P_TSQ_WEB);
|
||||
|
||||
PG_RETURN_TSQUERY(query);
|
||||
}
|
||||
|
||||
Datum
|
||||
websearch_to_tsquery(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *in = PG_GETARG_TEXT_PP(0);
|
||||
Oid cfgId;
|
||||
|
||||
cfgId = getTSCurrentConfig(true);
|
||||
PG_RETURN_DATUM(DirectFunctionCall2(websearch_to_tsquery_byid,
|
||||
ObjectIdGetDatum(cfgId),
|
||||
PointerGetDatum(in)));
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user