minor bug fix
This commit is contained in:
@@ -435,6 +435,37 @@ async def search_dfg_projects(
|
||||
|
||||
elif keywords:
|
||||
keyword_clauses = []
|
||||
#Add highlighting for the title and abstract fields
|
||||
title_abstract_query = {
|
||||
"bool": {
|
||||
"should": [
|
||||
{
|
||||
"multi_match": {
|
||||
"query": keyword,
|
||||
"fields": ["title_de", "title_en", "abstract_de", "abstract_en"],
|
||||
"type": "phrase_prefix",
|
||||
"max_expansions": 100,
|
||||
}
|
||||
}
|
||||
for keyword in keywords if keyword.strip()
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
|
||||
body["highlight"] = {
|
||||
"fragment_size": 200,
|
||||
"number_of_fragments": 0,
|
||||
"pre_tags": ["<em>"],
|
||||
"post_tags": ["</em>"],
|
||||
"require_field_match": True,
|
||||
"fields": {
|
||||
"title_de": {"highlight_query": title_abstract_query},
|
||||
"title_en": {"highlight_query": title_abstract_query},
|
||||
"abstract_de": {"highlight_query": title_abstract_query},
|
||||
"abstract_en": {"highlight_query": title_abstract_query},
|
||||
},
|
||||
}
|
||||
for keyword in keywords:
|
||||
if keyword.strip() == "":
|
||||
continue
|
||||
@@ -631,38 +662,7 @@ async def search_dfg_projects(
|
||||
sort_config = {"_score": {"order": "desc"}}
|
||||
|
||||
body["sort"] = [sort_config]
|
||||
|
||||
#Add highlighting for the title and abstract fields
|
||||
title_abstract_query = {
|
||||
"bool": {
|
||||
"should": [
|
||||
{
|
||||
"multi_match": {
|
||||
"query": keyword,
|
||||
"fields": ["title_de", "title_en", "abstract_de", "abstract_en"],
|
||||
"type": "phrase_prefix",
|
||||
"max_expansions": 100,
|
||||
}
|
||||
}
|
||||
for keyword in keywords if keyword.strip()
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
|
||||
body["highlight"] = {
|
||||
"fragment_size": 200,
|
||||
"number_of_fragments": 0,
|
||||
"pre_tags": ["<em>"],
|
||||
"post_tags": ["</em>"],
|
||||
"require_field_match": True,
|
||||
"fields": {
|
||||
"title_de": {"highlight_query": title_abstract_query},
|
||||
"title_en": {"highlight_query": title_abstract_query},
|
||||
"abstract_de": {"highlight_query": title_abstract_query},
|
||||
"abstract_en": {"highlight_query": title_abstract_query},
|
||||
},
|
||||
}
|
||||
# print(f"Executing DFG project search with body: {json.dumps(body, indent=2)}")
|
||||
# === Execute Search ===
|
||||
print(f"Executing DFG project search with body: {body}")
|
||||
|
||||
Reference in New Issue
Block a user