PgTsQuery
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Owns a PostgreSQL tsquery, lexemes combined with Boolean and phrase operators, as the bytes PostgreSQL stores, as
pgrx’s TsQueryBuf does. The default value is the empty tsquery.
public readonly struct PgTsQuery : IComparable<PgTsQuery>, IEquatable<PgTsQuery>Equality and hashing follow PostgreSQL’s comparison, which ignores an operand’s labels and prefix flag, so
‘a:A’ equals ‘a’, as in SQL and pgrx. Except for identical stored bytes they call PostgreSQL, as parsing,
formatting, combining and ordering do, so they need a backend callback.
Implements: IComparable<PgTsQuery>, IEquatable<PgTsQuery>
Methods
Section titled “Methods”And(PgTsQuery)
Section titled “And(PgTsQuery)”Matches documents that match both queries, as && does.
public PgTsQuery And(PgTsQuery other)Parameters:
other — PgTsQuery
The other query.
Returns: PgTsQuery
The combined query.
CompareTo(PgTsQuery)
Section titled “CompareTo(PgTsQuery)”Orders two tsqueries as PostgreSQL’s comparison operators do.
public int CompareTo(PgTsQuery other)Parameters:
other — PgTsQuery
The other tsquery.
Returns: int
A negative, zero or positive comparison.
Equals(PgTsQuery)
Section titled “Equals(PgTsQuery)”Compares two tsqueries as PostgreSQL’s = does.
public bool Equals(PgTsQuery other)Parameters:
other — PgTsQuery
The other tsquery.
Returns: bool
Whether PostgreSQL considers them equal.
Equals(object)
Section titled “Equals(object)”public override bool Equals(object obj)Parameters:
obj — object
Returns: bool
FollowedBy(PgTsQuery, int)
Section titled “FollowedBy(PgTsQuery, int)”Matches documents where a match of the other query follows a match of this one, as <-> or
tsquery_phrase(this, other, distance) does.
public PgTsQuery FollowedBy(PgTsQuery other, int distance = 1)Parameters:
other — PgTsQuery
The query that follows.
distance — int
How many positions later it follows, from 0 to 16384.
Returns: PgTsQuery
The phrase query.
FromPhraseText(PgTsConfig, string)
Section titled “FromPhraseText(PgTsConfig, string)”Matches the words of plain text as a phrase with a configuration, as phraseto_tsquery(config, text) does.
public static PgTsQuery FromPhraseText(PgTsConfig config, string text)Parameters:
config — PgTsConfig
The configuration.
text — string
The words.
Returns: PgTsQuery
The tsquery.
FromPhraseText(string)
Section titled “FromPhraseText(string)”Matches the words of plain text as a phrase with the current configuration, as phraseto_tsquery does.
public static PgTsQuery FromPhraseText(string text)Parameters:
text — string
The words.
Returns: PgTsQuery
The tsquery.
FromPlainText(PgTsConfig, string)
Section titled “FromPlainText(PgTsConfig, string)”Matches every word of plain text with a configuration, as plainto_tsquery(config, text) does.
public static PgTsQuery FromPlainText(PgTsConfig config, string text)Parameters:
config — PgTsConfig
The configuration.
text — string
The words.
Returns: PgTsQuery
The tsquery.
FromPlainText(string)
Section titled “FromPlainText(string)”Matches every word of plain text with the current configuration, as plainto_tsquery does.
public static PgTsQuery FromPlainText(string text)Parameters:
text — string
The words.
Returns: PgTsQuery
The tsquery.
FromText(PgTsConfig, string)
Section titled “FromText(PgTsConfig, string)”Parses a query with a configuration, as to_tsquery(config, text) does.
public static PgTsQuery FromText(PgTsConfig config, string text)Parameters:
config — PgTsConfig
The configuration.
text — string
The query.
Returns: PgTsQuery
The tsquery.
Exceptions:
- PgException: The text isn’t a query, SQLSTATE 42601.
FromText(string)
Section titled “FromText(string)”Parses a query with the current configuration, normalizing its words, as to_tsquery does.
public static PgTsQuery FromText(string text)Parameters:
text — string
A query such as fat & rats.
Returns: PgTsQuery
The tsquery.
Exceptions:
- PgException: The text isn’t a query, SQLSTATE 42601.
FromWebSearchText(PgTsConfig, string)
Section titled “FromWebSearchText(PgTsConfig, string)”Parses web search syntax with a configuration, as websearch_to_tsquery(config, text) does.
public static PgTsQuery FromWebSearchText(PgTsConfig config, string text)Parameters:
config — PgTsConfig
The configuration.
text — string
The search.
Returns: PgTsQuery
The tsquery.
FromWebSearchText(string)
Section titled “FromWebSearchText(string)”Parses web search syntax with the current configuration, as websearch_to_tsquery does: quoted phrases,
or and a leading -.
public static PgTsQuery FromWebSearchText(string text)Parameters:
text — string
The search.
Returns: PgTsQuery
The tsquery.
GetHashCode()
Section titled “GetHashCode()”Hashes the operands’ text and the operators in stored order, which PostgreSQL’s comparison distinguishes, as pgrx’s hash does.
public override int GetHashCode()Returns: int
The hash.
GetItems()
Section titled “GetItems()”Reads the items in stored prefix order, as pgrx’s TsQuery::items does: each operator precedes its right
operand, then its left.
public IReadOnlyList<PgTsQueryItem> GetItems()Returns: IReadOnlyList<PgTsQueryItem>
The items.
Matches documents that don’t match this query, as !! does.
public PgTsQuery Not()Returns: PgTsQuery
The negated query.
Or(PgTsQuery)
Section titled “Or(PgTsQuery)”Matches documents that match either query, as || does.
public PgTsQuery Or(PgTsQuery other)Parameters:
other — PgTsQuery
The other query.
Returns: PgTsQuery
The combined query.
Parse(string)
Section titled “Parse(string)”Parses a tsquery’s text, as a cast to tsquery does, without normalizing words.
public static PgTsQuery Parse(string text)Parameters:
text — string
A query such as ‘fat’ & (‘rat’ | ‘cat’).
Returns: PgTsQuery
The tsquery.
Exceptions:
- PgException: The text isn’t a tsquery.
ToString()
Section titled “ToString()”Formats the tsquery as PostgreSQL does, such as ‘fat’ & ‘rat’.
public override string ToString()Returns: string
The text.
Operators
Section titled “Operators”operator &(PgTsQuery, PgTsQuery)
Section titled “operator &(PgTsQuery, PgTsQuery)”Matches documents that match both queries.
public static PgTsQuery operator &(PgTsQuery left, PgTsQuery right)Parameters:
left — PgTsQuery
The first query.
right — PgTsQuery
The second query.
Returns: PgTsQuery
The combined query.
operator |(PgTsQuery, PgTsQuery)
Section titled “operator |(PgTsQuery, PgTsQuery)”Matches documents that match either query.
public static PgTsQuery operator |(PgTsQuery left, PgTsQuery right)Parameters:
left — PgTsQuery
The first query.
right — PgTsQuery
The second query.
Returns: PgTsQuery
The combined query.
operator ==(PgTsQuery, PgTsQuery)
Section titled “operator ==(PgTsQuery, PgTsQuery)”public static bool operator ==(PgTsQuery left, PgTsQuery right)Parameters:
left — PgTsQuery
right — PgTsQuery
Returns: bool
operator >(PgTsQuery, PgTsQuery)
Section titled “operator >(PgTsQuery, PgTsQuery)”Orders two tsqueries as PostgreSQL does.
public static bool operator >(PgTsQuery left, PgTsQuery right)Parameters:
left — PgTsQuery
The left tsquery.
right — PgTsQuery
The right tsquery.
Returns: bool
Whether the left sorts last.
operator >=(PgTsQuery, PgTsQuery)
Section titled “operator >=(PgTsQuery, PgTsQuery)”Orders two tsqueries as PostgreSQL does.
public static bool operator >=(PgTsQuery left, PgTsQuery right)Parameters:
left — PgTsQuery
The left tsquery.
right — PgTsQuery
The right tsquery.
Returns: bool
Whether the left doesn’t sort first.
operator !=(PgTsQuery, PgTsQuery)
Section titled “operator !=(PgTsQuery, PgTsQuery)”public static bool operator !=(PgTsQuery left, PgTsQuery right)Parameters:
left — PgTsQuery
right — PgTsQuery
Returns: bool
operator <(PgTsQuery, PgTsQuery)
Section titled “operator <(PgTsQuery, PgTsQuery)”Orders two tsqueries as PostgreSQL does.
public static bool operator <(PgTsQuery left, PgTsQuery right)Parameters:
left — PgTsQuery
The left tsquery.
right — PgTsQuery
The right tsquery.
Returns: bool
Whether the left sorts first.
operator <=(PgTsQuery, PgTsQuery)
Section titled “operator <=(PgTsQuery, PgTsQuery)”Orders two tsqueries as PostgreSQL does.
public static bool operator <=(PgTsQuery left, PgTsQuery right)Parameters:
left — PgTsQuery
The left tsquery.
right — PgTsQuery
The right tsquery.
Returns: bool
Whether the left doesn’t sort last.
operator !(PgTsQuery)
Section titled “operator !(PgTsQuery)”Matches documents that don’t match the query.
public static PgTsQuery operator !(PgTsQuery query)Parameters:
query — PgTsQuery
The query.
Returns: PgTsQuery
The negated query.