fix: prioritize current company registration act

This commit is contained in:
2026-09-16 09:56:11 +03:00
parent af6b0b8098
commit c048f20734
5 changed files with 12 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ LEGAL_FORM_ALIASES = {
"жоопкерчилиги чектелген коом": ("жчк",),
},
}
COMPANY_REGISTRATION_DOCUMENTS = ("667", "4")
COMPANY_REGISTRATION_DOCUMENTS = (("230044970", 3000), ("667", 2000), ("4", 1000))
def query_variants(language: str, query: str) -> list[str]:
@@ -75,7 +75,7 @@ def company_registration_clauses(language: str, query: str) -> list[dict]:
}
}
return [clause(COMPANY_REGISTRATION_DOCUMENTS[0], 2000), clause(COMPANY_REGISTRATION_DOCUMENTS[1], 1000)]
return [clause(code, boost) for code, boost in COMPANY_REGISTRATION_DOCUMENTS]
def build_search_query(language: str, query: str) -> dict:
@@ -93,7 +93,7 @@ def build_search_query(language: str, query: str) -> dict:
]
planned = {"should": [*full_text, *intent_clauses], "minimum_should_match": 1}
if intent_clauses:
planned["filter"] = [{"terms": {"document_code": list(COMPANY_REGISTRATION_DOCUMENTS)}}]
planned["filter"] = [{"terms": {"document_code": [code for code, _ in COMPANY_REGISTRATION_DOCUMENTS]}}]
return {"bool": planned}