Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions apps/labrinth/src/search/backend/typesense/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ pub struct RequestConfig {
pub prioritize_exact_match: bool,
#[serde(default = "default_prioritize_num_matching_fields")]
pub prioritize_num_matching_fields: bool,
#[serde(default = "default_prioritize_token_positions")]
pub prioritize_token_positions: bool,
#[serde(default = "default_drop_tokens_threshold")]
pub drop_tokens_threshold: usize,
#[serde(default)]
pub text_match_type: TextMatchType,
#[serde(default)]
Expand All @@ -98,6 +102,8 @@ impl Default for RequestConfig {
prioritize_exact_match: default_prioritize_exact_match(),
prioritize_num_matching_fields:
default_prioritize_num_matching_fields(),
prioritize_token_positions: default_prioritize_token_positions(),
drop_tokens_threshold: default_drop_tokens_threshold(),
text_match_type: TextMatchType::default(),
bucketing: Bucketing::default(),
}
Expand Down Expand Up @@ -134,6 +140,14 @@ const fn default_prioritize_num_matching_fields() -> bool {
false
}

const fn default_prioritize_token_positions() -> bool {
true
}

const fn default_drop_tokens_threshold() -> usize {
0
}

impl TypesenseConfig {
pub fn new(meta_namespace: Option<String>) -> Self {
Self {
Expand Down Expand Up @@ -696,6 +710,14 @@ impl SearchBackend for Typesense {
.prioritize_num_matching_fields
.to_string(),
),
(
"prioritize_token_positions",
info.typesense_config.prioritize_token_positions.to_string(),
),
(
"drop_tokens_threshold",
info.typesense_config.drop_tokens_threshold.to_string(),
),
(
"text_match_type",
info.typesense_config.text_match_type.as_str().to_string(),
Expand Down
Loading