Skip to content

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>

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.

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.

Compares the stored bytes.

public bool Equals(PgTsVector other)

Parameters:

other — PgTsVector

The other tsvector.

Returns: bool

Whether both store the same bytes.

public override bool Equals(object obj)

Parameters:

obj — object

Returns: bool

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.

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.

Hashes the stored bytes, consistent with equality.

public override int GetHashCode()

Returns: int

The hash.

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.

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.

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:

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.

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.

Formats the tsvector as PostgreSQL does, such as ‘fat’:2 ‘rat’:3.

public override string ToString()

Returns: string

The text.

Gets the number of lexemes, as length(tsvector) does.

public int Count { get; }

Value: int

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.

public static bool operator ==(PgTsVector left, PgTsVector right)

Parameters:

left — PgTsVector

right — PgTsVector

Returns: bool

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.

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.

public static bool operator !=(PgTsVector left, PgTsVector right)

Parameters:

left — PgTsVector

right — PgTsVector

Returns: bool

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.

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.