mirror of
https://github.com/modrinth/code.git
synced 2026-09-04 22:10:15 +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_id": {"type": "keyword"},
|
||||||
"project_types": {"type": "keyword"},
|
"project_types": {"type": "keyword"},
|
||||||
"all_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"},
|
"categories": {"type": "keyword"},
|
||||||
"project_categories": {"type": "keyword"},
|
"project_categories": {"type": "keyword"},
|
||||||
"display_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(
|
async fn import_projects(
|
||||||
&self,
|
&self,
|
||||||
indices: &[String],
|
indices: &[String],
|
||||||
@@ -862,20 +884,45 @@ impl Elasticsearch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
json!({
|
json!({
|
||||||
"multi_match": {
|
"dis_max": {
|
||||||
"query": query,
|
"queries": [
|
||||||
"fields": [
|
Self::native_prefix_tier(query, &["name"], 4),
|
||||||
"name",
|
Self::native_prefix_tier(
|
||||||
"indexed_name",
|
query,
|
||||||
"slug",
|
&["indexed_name", "slug"],
|
||||||
"author",
|
3,
|
||||||
"indexed_author",
|
),
|
||||||
"summary"
|
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(
|
async fn search_for_project_raw_native(
|
||||||
&self,
|
&self,
|
||||||
info: &SearchRequest,
|
info: &SearchRequest,
|
||||||
|
|||||||
@@ -1852,8 +1852,6 @@ impl Elasticsearch {
|
|||||||
pub(super) fn typesense_parity_index_schema() -> Value {
|
pub(super) fn typesense_parity_index_schema() -> Value {
|
||||||
json!({
|
json!({
|
||||||
"settings": {
|
"settings": {
|
||||||
"number_of_shards": 3,
|
|
||||||
"number_of_replicas": 1,
|
|
||||||
"refresh_interval": "30s",
|
"refresh_interval": "30s",
|
||||||
"index.mapping.total_fields.limit": 5000,
|
"index.mapping.total_fields.limit": 5000,
|
||||||
"analysis": {
|
"analysis": {
|
||||||
|
|||||||
Reference in New Issue
Block a user