change names matching to match_phrase
This commit is contained in:
@@ -665,33 +665,18 @@ async def search_dfg_projects(
|
||||
)
|
||||
if names:
|
||||
name_must_clauses = []
|
||||
|
||||
for full_name in names:
|
||||
name_parts = full_name.strip().split()
|
||||
if not name_parts:
|
||||
full_name = full_name.strip()
|
||||
if not full_name:
|
||||
continue
|
||||
|
||||
match_musts = []
|
||||
|
||||
for part in name_parts:
|
||||
match_musts.append(
|
||||
{
|
||||
"match": {
|
||||
"persons.full_name": {
|
||||
"query": part,
|
||||
"operator": "and",
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
name_must_clauses.append(
|
||||
{
|
||||
"nested": {
|
||||
"path": "persons",
|
||||
"query": {
|
||||
"bool": {
|
||||
"must": match_musts
|
||||
"match_phrase": {
|
||||
"persons.full_name": full_name
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -779,6 +764,7 @@ async def search_dfg_projects(
|
||||
sort_config = {"id": {"order": sort_direction}}
|
||||
|
||||
body["sort"] = [sort_config]
|
||||
print(body)
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_DFG_ALL,
|
||||
body=body,
|
||||
|
||||
Reference in New Issue
Block a user