mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 12:05:53 +00:00
approach parity even without explicit parity enabled
This commit is contained in:
@@ -739,6 +739,12 @@ impl Elasticsearch {
|
||||
"project_id": {"type": "keyword"},
|
||||
"project_types": {"type": "keyword"},
|
||||
"all_project_types": {"type": "keyword"},
|
||||
"slug": Self::native_text_field_schema(),
|
||||
"author": Self::native_text_field_schema(),
|
||||
"indexed_author": Self::native_text_field_schema(),
|
||||
"name": Self::native_text_field_schema(),
|
||||
"indexed_name": Self::native_text_field_schema(),
|
||||
"summary": Self::native_text_field_schema(),
|
||||
"categories": {"type": "keyword"},
|
||||
"project_categories": {"type": "keyword"},
|
||||
"display_categories": {"type": "keyword"},
|
||||
@@ -779,6 +785,22 @@ impl Elasticsearch {
|
||||
})
|
||||
}
|
||||
|
||||
fn native_text_field_schema() -> Value {
|
||||
json!({
|
||||
"type": "text",
|
||||
"index_prefixes": {
|
||||
"min_chars": 1,
|
||||
"max_chars": 10
|
||||
},
|
||||
"fields": {
|
||||
"keyword": {
|
||||
"type": "keyword",
|
||||
"ignore_above": 256
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async fn import_projects(
|
||||
&self,
|
||||
indices: &[String],
|
||||
@@ -862,20 +884,45 @@ impl Elasticsearch {
|
||||
}
|
||||
|
||||
json!({
|
||||
"multi_match": {
|
||||
"query": query,
|
||||
"fields": [
|
||||
"name",
|
||||
"indexed_name",
|
||||
"slug",
|
||||
"author",
|
||||
"indexed_author",
|
||||
"summary"
|
||||
"dis_max": {
|
||||
"queries": [
|
||||
Self::native_prefix_tier(query, &["name"], 4),
|
||||
Self::native_prefix_tier(
|
||||
query,
|
||||
&["indexed_name", "slug"],
|
||||
3,
|
||||
),
|
||||
Self::native_prefix_tier(
|
||||
query,
|
||||
&["author", "indexed_author"],
|
||||
2,
|
||||
),
|
||||
Self::native_prefix_tier(query, &["summary"], 1),
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn native_prefix_tier(
|
||||
query: &str,
|
||||
fields: &[&str],
|
||||
boost: u8,
|
||||
) -> Value {
|
||||
json!({
|
||||
"constant_score": {
|
||||
"filter": {
|
||||
"multi_match": {
|
||||
"query": query,
|
||||
"type": "bool_prefix",
|
||||
"operator": "and",
|
||||
"fields": fields
|
||||
}
|
||||
},
|
||||
"boost": boost
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async fn search_for_project_raw_native(
|
||||
&self,
|
||||
info: &SearchRequest,
|
||||
|
||||
@@ -1852,8 +1852,6 @@ impl Elasticsearch {
|
||||
pub(super) fn typesense_parity_index_schema() -> Value {
|
||||
json!({
|
||||
"settings": {
|
||||
"number_of_shards": 3,
|
||||
"number_of_replicas": 1,
|
||||
"refresh_interval": "30s",
|
||||
"index.mapping.total_fields.limit": 5000,
|
||||
"analysis": {
|
||||
|
||||
Reference in New Issue
Block a user