From efdfb511494735a5ae2fffde3eeccc7da38ba652 Mon Sep 17 00:00:00 2001 From: Prospector <6166773+Prospector@users.noreply.github.com> Date: Wed, 8 Jul 2026 08:04:21 -0700 Subject: [PATCH] fix: add DEI (downloads, equality, and inequality) (#6664) fix: add DEI --- apps/labrinth/src/search/backend/typesense/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/labrinth/src/search/backend/typesense/mod.rs b/apps/labrinth/src/search/backend/typesense/mod.rs index 89fd29ffd4..6a9d1b91f9 100644 --- a/apps/labrinth/src/search/backend/typesense/mod.rs +++ b/apps/labrinth/src/search/backend/typesense/mod.rs @@ -571,6 +571,7 @@ impl Typesense { json!({"name": "indexed_name", "type": "string", "facet": false, "stem": true}), json!({"name": "indexed_author", "type": "string", "facet": false}), json!({"name": "log_downloads", "type": "float", "sort": true}), + json!({"name": "downloads", "type": "int32", "sort": true}), json!({"name": "follows", "type": "int32", "facet": true, "sort": true}), json!({"name": "created_timestamp", "type": "int64", "sort": true}), json!({"name": "modified_timestamp", "type": "int64", "sort": true}), @@ -1263,9 +1264,12 @@ fn facets_to_typesense(facets_json: &str) -> Result { /// Converts a single facet condition such as `"categories:mods"`, /// `"categories=mods"`, or `"downloads!=100"` into a Typesense filter clause. fn condition_to_typesense_filter(cond: &str) -> String { - // Handle `!=` before `=` so we don't misfire on the equality arm. - if let Some((field, value)) = cond.split_once("!=") { - return format!("{}:!= {}", field.trim(), value.trim()); + // Match multi-character operators before their single-character prefixes, + // and range/inequality operators before the plain `=` equality arm. + for op in ["!=", ">=", "<=", ">", "<"] { + if let Some((field, value)) = cond.split_once(op) { + return format!("{}:{} {}", field.trim(), op, value.trim()); + } } if let Some((field, value)) = cond.split_once(':') { return format!("{}:= {}", field.trim(), value.trim());