Manipulating Queries
GaussDB provides functions and operators that can be used to manipulate queries that are already in tsquery type.
- numnode(query tsquery) returns integer
Returns the number of nodes (lexemes plus operators) in a tsquery. This function is useful to determine if the query is meaningful (returns > 0), or contains only stop words (returns 0). Example:
1 2 3 4 5 6 7 8 9 10 11
openGauss=# SELECT numnode(plainto_tsquery('the any')); NOTICE: text-search query contains only stop words or doesn't contain lexemes, ignored CONTEXT: referenced column: numnode numnode --------- 0 openGauss=# SELECT numnode('foo & bar'::tsquery); numnode --------- 3
- querytree(query tsquery) returns text
Returns the portion of a tsquery that can be used for searching an index. This function is useful for detecting non-index queries, for example those containing only stop words or only negated terms. Example:
1 2 3 4 5
openGauss=# SELECT querytree(to_tsquery('!defined')); querytree ----------- T (1 row)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot