From 0f212d189ea17c734466c0a0c72b9930a0022f2e Mon Sep 17 00:00:00 2001 From: genja Date: Wed, 10 Jun 2026 14:13:28 +0200 Subject: [PATCH] removed fuzziness from person names matching + added applying rescoring strategy when query is empty --- .../src/main/inse/persons/query_builder.py | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/service/src/main/inse/persons/query_builder.py b/service/src/main/inse/persons/query_builder.py index 01bd9343..a258b99a 100644 --- a/service/src/main/inse/persons/query_builder.py +++ b/service/src/main/inse/persons/query_builder.py @@ -275,14 +275,13 @@ def build_authors_search_rescored( } } }, - # { - # "match": { - # "display_name": { - # "query": query, - # "fuzziness": 1 - # } - # } - # } + { + "match": { + "display_name": { + "query": query + } + } + } ], "minimum_should_match": 1 } @@ -473,7 +472,7 @@ def build_authors_search_rescored( functions.append(works_count_boost_query) # Combine query and filters body = {} - + if functions: inner_query = None if query_clause: @@ -486,6 +485,15 @@ def build_authors_search_rescored( } else: inner_query = query_clause + # if query not null then multiply with name matching + body["query"] = { + "function_score": { + "query": inner_query, + "functions": functions, + "score_mode": "multiply", + "boost_mode": "multiply" + } + } else: if filter_clauses: inner_query = { @@ -495,15 +503,15 @@ def build_authors_search_rescored( } else: inner_query = {"match_all": {}} - - body["query"] = { - "function_score": { - "query": inner_query, - "functions": functions, - "score_mode": "multiply", - "boost_mode": "replace" + # if the query is null, replace the scoring completely + body["query"] = { + "function_score": { + "query": inner_query, + "functions": functions, + "score_mode": "multiply", + "boost_mode": "replace" + } } - } else: if query_clause: if filter_clauses: