|
19 | 19 | from django.http import HttpRequest
|
20 | 20 | from django.http.request import QueryDict
|
21 | 21 | from django_elasticsearch_dsl.search import Search
|
22 |
| -from elasticsearch.exceptions import RequestError, TransportError |
| 22 | +from elasticsearch.exceptions import ApiError, RequestError, TransportError |
23 | 23 | from elasticsearch_dsl import A, MultiSearch, Q
|
24 | 24 | from elasticsearch_dsl import Search as SearchDSL
|
25 | 25 | from elasticsearch_dsl.connections import connections
|
@@ -1640,19 +1640,26 @@ def fetch_es_results(
|
1640 | 1640 | child_total = child_doc_count_response.hits.total.value
|
1641 | 1641 |
|
1642 | 1642 | query_time = main_response.took
|
1643 |
| - error = False |
1644 | 1643 | search_type = get_params.get("type", SEARCH_TYPES.OPINION)
|
1645 | 1644 | if (
|
1646 | 1645 | main_response.aggregations
|
1647 | 1646 | and search_type == SEARCH_TYPES.PARENTHETICAL
|
1648 | 1647 | ):
|
1649 | 1648 | main_response = main_response.aggregations.groups.buckets
|
| 1649 | + error = False |
1650 | 1650 | return main_response, query_time, error, parent_total, child_total
|
1651 | 1651 | except (TransportError, ConnectionError, RequestError) as e:
|
1652 |
| - logger.warning(f"Error loading search page with request: {get_params}") |
1653 |
| - logger.warning(f"Error was: {e}") |
| 1652 | + logger.warning( |
| 1653 | + "Error loading search page with request: %s", dict(get_params) |
| 1654 | + ) |
| 1655 | + logger.warning("Error was: %s", e) |
1654 | 1656 | if settings.DEBUG is True:
|
1655 | 1657 | traceback.print_exc()
|
| 1658 | + except ApiError as e: |
| 1659 | + if "Failed to parse query" in str(e): |
| 1660 | + logger.warning("Failed to parse query: %s", e) |
| 1661 | + else: |
| 1662 | + logger.error("Multi-search API Error: %s", e) |
1656 | 1663 | return [], 0, error, None, None
|
1657 | 1664 |
|
1658 | 1665 |
|
|
0 commit comments