Improve tax profit search relevance
This commit is contained in:
@@ -47,7 +47,17 @@ class SearchApiTest(unittest.TestCase):
|
||||
self.assertEqual(planned["minimum_should_match"], 1)
|
||||
self.assertNotIn("filter", planned)
|
||||
self.assertTrue(any("constant_score" in clause for clause in planned["should"]))
|
||||
self.assertTrue(any("общество с ограниченной ответственностью" in clause.get("multi_match", {}).get("query", "") for clause in planned["should"]))
|
||||
self.assertTrue(any("общество с ограниченной ответственностью" in clause.get("match", {}).get("text_ru", {}).get("query", "") for clause in planned["should"]))
|
||||
|
||||
def test_production_api_boosts_tax_code_for_profit_tax_query(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
api = self.make_api(Path(temporary))
|
||||
with patch("search.api.request_json", return_value={"hits": {"hits": []}}) as request:
|
||||
api.handle("GET", "/search?q=%D0%BD%D0%B0%D0%BB%D0%BE%D0%B3+%D0%BD%D0%B0+%D0%BF%D1%80%D0%B8%D0%B1%D1%8B%D0%BB%D1%8C&language=ru")
|
||||
body = json.loads(request.call_args.args[2])
|
||||
planned = body["query"]["bool"]["must"]["bool"]
|
||||
anchors = [clause["constant_score"]["filter"]["bool"]["filter"][0] for clause in planned["should"] if "constant_score" in clause]
|
||||
self.assertIn({"term": {"document_code": "112340"}}, anchors)
|
||||
|
||||
def test_search_sorts_repealed_documents_after_other_statuses(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
|
||||
Reference in New Issue
Block a user