enum

PgORM::FullTextSearch::RankFunction

Inherits Enum < Comparable < Value < Object

Ranking function type for relevance scoring.

PostgreSQL provides two ranking functions:

  • Rank: Standard ranking based on term frequency (ts_rank)
  • RankCD: Cover density ranking, considers proximity of terms (ts_rank_cd)

Cover density ranking often produces better results for phrase searches and when term proximity matters.

Example

# Standard ranking
Article.search_ranked("crystal", :content, rank_function: RankFunction::Rank)

# Cover density ranking (better for phrases)
Article.search_ranked("crystal programming", :content, rank_function: RankFunction::RankCD)

Constants

Rank = 0
RankCD = 1

Instance methods

rank?

Returns true if this enum value equals Rank

Source
rank_cd?

Returns true if this enum value equals RankCD

Source
to_s

Returns a String representation of this enum member. In the case of regular enums, this is just the name of the member. In the case of flag enums, it's the names joined by vertical bars, or "None", if the value is zero.

If an enum's value doesn't match a member's value, the raw value is returned as a string.

Color::Red.to_s                     # => "Red"
IOMode::None.to_s                   # => "None"
(IOMode::Read | IOMode::Write).to_s # => "Read | Write"

Color.new(10).to_s # => "10"
Source