feat: add all_project_types to search results (#6654)

* feat: add all_project_types to search results

* update docs
This commit is contained in:
Prospector
2026-07-07 21:30:42 +00:00
committed by GitHub
parent 3ed75a146a
commit 96ab120cd0
6 changed files with 40 additions and 0 deletions
+8
View File
@@ -692,6 +692,12 @@ components:
type: string type: string
description: The ID of the project description: The ID of the project
example: AABBCCDD example: AABBCCDD
all_project_types:
type: array
items:
type: string
description: All project types across every version of the project, unlike `project_type` which only reflects a version-specific type
example: [mod, plugin, datapack]
author: author:
type: string type: string
description: The username of the project's author description: The username of the project's author
@@ -748,6 +754,7 @@ components:
- client_side - client_side
- server_side - server_side
- project_id - project_id
- all_project_types
- author - author
- versions - versions
- follows - follows
@@ -1948,6 +1955,7 @@ paths:
These are the most commonly used facet types: These are the most commonly used facet types:
- `project_type` - `project_type`
- `all_project_types` (matches against every project type across all of the project's versions, not just the primary/version-specific type)
- `categories` (loaders are lumped in with categories in search) - `categories` (loaders are lumped in with categories in search)
- `versions` - `versions`
- `client_side` - `client_side`
+2
View File
@@ -15,6 +15,7 @@ pub struct LegacySearchResults {
pub struct LegacyResultSearchProject { pub struct LegacyResultSearchProject {
pub project_id: String, pub project_id: String,
pub project_type: String, pub project_type: String,
pub all_project_types: Vec<String>,
pub slug: Option<String>, pub slug: Option<String>,
pub author: String, pub author: String,
#[serde(default)] #[serde(default)]
@@ -136,6 +137,7 @@ impl LegacyResultSearchProject {
Self { Self {
project_type, project_type,
all_project_types: result_search_project.all_project_types,
client_side, client_side,
server_side, server_side,
versions, versions,
@@ -405,6 +405,14 @@ impl SearchField {
optional: true, optional: true,
token_separators: &["-"], token_separators: &["-"],
}, },
SearchField::AllProjectTypes => TypesenseFieldSpec {
path: "all_project_types",
ty: "string[]",
facet: true,
sort: false,
optional: true,
token_separators: &["-"],
},
SearchField::ProjectId => TypesenseFieldSpec { SearchField::ProjectId => TypesenseFieldSpec {
path: "project_id", path: "project_id",
ty: "string", ty: "string",
+15
View File
@@ -495,6 +495,20 @@ async fn build_search_documents(
.flat_map(|x| x.loaders.clone()) .flat_map(|x| x.loaders.clone())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
// all valid project types across every version of the project, so that
// filters can exclude projects that have *any* version of a given
// project type (unlike the version-specific `project_types` field).
let mut all_project_types = versions
.iter()
.flat_map(|x| x.project_types.clone())
.collect::<Vec<_>>();
all_project_types.sort();
all_project_types.dedup();
exp::compat::correct_project_types(
&project.components,
&mut all_project_types,
);
for version in versions { for version in versions {
let version_fields = VersionField::from_query_json( let version_fields = VersionField::from_query_json(
version.version_fields, version.version_fields,
@@ -609,6 +623,7 @@ async fn build_search_documents(
slug: project.slug.clone(), slug: project.slug.clone(),
// TODO // TODO
project_types, project_types,
all_project_types: all_project_types.clone(),
gallery: gallery.clone(), gallery: gallery.clone(),
featured_gallery: featured_gallery.clone(), featured_gallery: featured_gallery.clone(),
open_source, open_source,
+5
View File
@@ -202,6 +202,7 @@ pub enum SearchField {
Author, Author,
License, License,
ProjectTypes, ProjectTypes,
AllProjectTypes,
ProjectId, ProjectId,
OpenSource, OpenSource,
Environment, Environment,
@@ -238,6 +239,7 @@ pub struct UploadSearchProject {
pub project_id: String, pub project_id: String,
// //
pub project_types: Vec<String>, pub project_types: Vec<String>,
pub all_project_types: Vec<String>,
pub slug: Option<String>, pub slug: Option<String>,
pub author: String, pub author: String,
pub author_id: String, pub author_id: String,
@@ -307,6 +309,8 @@ pub struct ResultSearchProject {
pub version_id: String, pub version_id: String,
pub project_id: String, pub project_id: String,
pub project_types: Vec<String>, pub project_types: Vec<String>,
#[serde(default)]
pub all_project_types: Vec<String>,
pub slug: Option<String>, pub slug: Option<String>,
pub author: String, pub author: String,
#[serde(default)] #[serde(default)]
@@ -355,6 +359,7 @@ impl From<UploadSearchProject> for ResultSearchProject {
version_id: source.version_id, version_id: source.version_id,
project_id: source.project_id, project_id: source.project_id,
project_types: source.project_types, project_types: source.project_types,
all_project_types: source.all_project_types,
slug: source.slug, slug: source.slug,
author: source.author, author: source.author,
author_id: Some(source.author_id), author_id: Some(source.author_id),
@@ -1742,6 +1742,7 @@ export namespace Labrinth {
export interface ResultSearchProject { export interface ResultSearchProject {
project_id: string project_id: string
project_type: string project_type: string
all_project_types: string[]
slug: string | null slug: string | null
author: string author: string
author_id: string | null author_id: string | null
@@ -1779,6 +1780,7 @@ export namespace Labrinth {
version_id: string version_id: string
project_id: string project_id: string
project_types: string[] project_types: string[]
all_project_types: string[]
slug: string | null slug: string | null
author: string author: string
author_id: string | null author_id: string | null