PgTsVector
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Owns a PostgreSQL tsvector, a sorted set of lexemes with their positions, as the bytes PostgreSQL stores, as pgrx’s
TsVectorBuf does. The default value is the empty tsvector.
public readonly struct PgTsVector : IComparable<PgTsVector>, IEquatable<PgTsVector>Equality compares the stored bytes, which PostgreSQL keeps sorted and unique, so values it built are equal when it considers them equal. Parsing, formatting, matching, ranking and ordering call PostgreSQL, so they need a backend callback.
Implements: IComparable<PgTsVector>, IEquatable<PgTsVector>
Methods
Section titled “Methods”CompareTo(PgTsVector)
Section titled “CompareTo(PgTsVector)”Orders two tsvectors as PostgreSQL’s comparison operators do.
public int CompareTo(PgTsVector other)Parameters:
other — PgTsVector
The other tsvector.
Returns: int
A negative, zero or positive comparison.
Concat(PgTsVector)
Section titled “Concat(PgTsVector)”Concatenates two documents, as || does, shifting the second’s positions past the first’s.
public PgTsVector Concat(PgTsVector other)Parameters:
other — PgTsVector
The document that follows.
Returns: PgTsVector
The concatenation.
Equals(PgTsVector)
Section titled “Equals(PgTsVector)”Compares the stored bytes.
public bool Equals(PgTsVector other)Parameters:
other — PgTsVector
The other tsvector.
Returns: bool
Whether both store the same bytes.
Equals(object)
Section titled “Equals(object)”public override bool Equals(object obj)Parameters:
obj — object
Returns: bool
FromText(PgTsConfig, string)
Section titled “FromText(PgTsConfig, string)”Normalizes a document with a configuration, as to_tsvector(config, document) does.
public static PgTsVector FromText(PgTsConfig config, string document)Parameters:
config — PgTsConfig
The configuration.
document — string
The document.
Returns: PgTsVector
The document’s lexemes.
FromText(string)
Section titled “FromText(string)”Normalizes a document with the current configuration, as to_tsvector does.
public static PgTsVector FromText(string document)Parameters:
document — string
The document.
Returns: PgTsVector
The document’s lexemes.
GetHashCode()
Section titled “GetHashCode()”Hashes the stored bytes, consistent with equality.
public override int GetHashCode()Returns: int
The hash.
GetLexemes()
Section titled “GetLexemes()”Reads the lexemes in stored order, each with its positions and labels, as pgrx’s TsVector::lexemes does.
public IReadOnlyList<PgTsLexeme> GetLexemes()Returns: IReadOnlyList<PgTsLexeme>
The lexemes.
Matches(PgTsQuery)
Section titled “Matches(PgTsQuery)”Tests whether this document matches a query, as @@ does.
public bool Matches(PgTsQuery query)Parameters:
query — PgTsQuery
The query.
Returns: bool
Whether the document matches.
Parse(string)
Section titled “Parse(string)”Parses a tsvector’s text, as a cast to tsvector does, without normalizing words.
public static PgTsVector Parse(string text)Parameters:
text — string
Lexemes such as ‘fat’:2 ‘rat’:3.
Returns: PgTsVector
The tsvector.
Exceptions:
- PgException: The text isn’t a tsvector.
Rank(PgTsQuery)
Section titled “Rank(PgTsQuery)”Ranks this document for a query by the frequency of its matching lexemes, as ts_rank does.
public float Rank(PgTsQuery query)Parameters:
query — PgTsQuery
The query.
Returns: float
The rank.
Rank(PgTsQuery, PgTsRankWeights?, PgTsRankNormalization)
Section titled “Rank(PgTsQuery, PgTsRankWeights?, PgTsRankNormalization)”Ranks this document for a query with label weights and a normalization, as ts_rank(weights, …) does.
public float Rank(PgTsQuery query, PgTsRankWeights? weights, PgTsRankNormalization normalization)Parameters:
query — PgTsQuery
The query.
weights — PgTsRankWeights?
The label weights, or null for PostgreSQL’s defaults.
normalization — PgTsRankNormalization
How the rank is normalized by document length.
Returns: float
The rank.
RankCoverDensity(PgTsQuery)
Section titled “RankCoverDensity(PgTsQuery)”Ranks this document for a query by the proximity of its matching lexemes, as ts_rank_cd does. The document
needs positions.
public float RankCoverDensity(PgTsQuery query)Parameters:
query — PgTsQuery
The query.
Returns: float
The rank.
RankCoverDensity(PgTsQuery, PgTsRankWeights?, PgTsRankNormalization)
Section titled “RankCoverDensity(PgTsQuery, PgTsRankWeights?, PgTsRankNormalization)”Ranks this document for a query by proximity, with label weights and a normalization, as
ts_rank_cd(weights, …) does.
public float RankCoverDensity(PgTsQuery query, PgTsRankWeights? weights, PgTsRankNormalization normalization)Parameters:
query — PgTsQuery
The query.
weights — PgTsRankWeights?
The label weights, or null for PostgreSQL’s defaults.
normalization — PgTsRankNormalization
How the rank is normalized by document length.
Returns: float
The rank.
ToString()
Section titled “ToString()”Formats the tsvector as PostgreSQL does, such as ‘fat’:2 ‘rat’:3.
public override string ToString()Returns: string
The text.
Properties
Section titled “Properties”Gets the number of lexemes, as length(tsvector) does.
public int Count { get; }Value: int
Operators
Section titled “Operators”operator |(PgTsVector, PgTsVector)
Section titled “operator |(PgTsVector, PgTsVector)”Concatenates two documents, as || does.
public static PgTsVector operator |(PgTsVector left, PgTsVector right)Parameters:
left — PgTsVector
The first document.
right — PgTsVector
The document that follows.
Returns: PgTsVector
The concatenation.
operator ==(PgTsVector, PgTsVector)
Section titled “operator ==(PgTsVector, PgTsVector)”public static bool operator ==(PgTsVector left, PgTsVector right)Parameters:
left — PgTsVector
right — PgTsVector
Returns: bool
operator >(PgTsVector, PgTsVector)
Section titled “operator >(PgTsVector, PgTsVector)”Orders two tsvectors as PostgreSQL does.
public static bool operator >(PgTsVector left, PgTsVector right)Parameters:
left — PgTsVector
The left tsvector.
right — PgTsVector
The right tsvector.
Returns: bool
Whether the left sorts last.
operator >=(PgTsVector, PgTsVector)
Section titled “operator >=(PgTsVector, PgTsVector)”Orders two tsvectors as PostgreSQL does.
public static bool operator >=(PgTsVector left, PgTsVector right)Parameters:
left — PgTsVector
The left tsvector.
right — PgTsVector
The right tsvector.
Returns: bool
Whether the left doesn’t sort first.
operator !=(PgTsVector, PgTsVector)
Section titled “operator !=(PgTsVector, PgTsVector)”public static bool operator !=(PgTsVector left, PgTsVector right)Parameters:
left — PgTsVector
right — PgTsVector
Returns: bool
operator <(PgTsVector, PgTsVector)
Section titled “operator <(PgTsVector, PgTsVector)”Orders two tsvectors as PostgreSQL does.
public static bool operator <(PgTsVector left, PgTsVector right)Parameters:
left — PgTsVector
The left tsvector.
right — PgTsVector
The right tsvector.
Returns: bool
Whether the left sorts first.
operator <=(PgTsVector, PgTsVector)
Section titled “operator <=(PgTsVector, PgTsVector)”Orders two tsvectors as PostgreSQL does.
public static bool operator <=(PgTsVector left, PgTsVector right)Parameters:
left — PgTsVector
The left tsvector.
right — PgTsVector
The right tsvector.
Returns: bool
Whether the left doesn’t sort last.