fix(backend/person_search): search failing due to unsupported search parameters
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/pr-dev This commit looks good

This commit is contained in:
Steven Tischer
2026-06-04 09:55:54 +02:00
parent 547a82336e
commit e0015c3ea9
2 changed files with 23 additions and 23 deletions
@@ -7,6 +7,10 @@ def search(
index: str,
query_field: str = None,
query_value: str = None,
query: dict = None,
source = None,
size: int = None,
sort: list = None,
body: dict = None,
) -> dict[str, Any]:
@@ -14,16 +18,26 @@ def search(
"Authorization": f"ApiKey {config.settings.elasticsearch_api_key}",
"Content-Type": "application/json"
}
payload = {
"query": {
"query_string": {
"default_field": query_field,
"query": query_value
if body is not None:
payload = body
elif query is not None:
payload = {"query": query}
if source is not None:
payload["_source"] = source
if size is not None:
payload["size"] = size
if sort is not None:
payload["sort"] = sort
else:
payload = {
"query": {
"query_string": {
"default_field": query_field,
"query": query_value
}
}
}
}
if body != None:
payload = body
with httpx.Client() as client:
response = client.post(
+1 -15
View File
@@ -395,15 +395,9 @@ def search_persons_by_name(
"minimum_should_match": 1,
}
}
body = {
"size":limit,
"query":search_query,
"_source":include.split(",") if include else True,
}
try:
response = elasticsearch.search(
index="openalex-authors",
body=body,
query=search_query,
source=include.split(",") if include else True,
size=limit,
@@ -438,19 +432,11 @@ def search_persons_by_institution(
},
}
}
body = {
"size":limit,
"query":search_query,
"_source":include.split(",") if include else True,
"sort":[{"works_count": {"order": "desc"}}]
}
try:
response = elasticsearch.search(
index="openalex-authors",
body=body,
source=include.split(",") if include else True,
query=search_query,
source=include.split(",") if include else True,
size=limit,
sort=[{"works_count": {"order": "desc"}}],
)