Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the workaround if we can't determine the server's version #581

Merged
merged 7 commits into from
Sep 15, 2023
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion eland/field_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Union,
)

import elasticsearch
import numpy as np
import pandas as pd # type: ignore
from pandas.core.dtypes.common import ( # type: ignore
Expand Down Expand Up @@ -942,7 +943,19 @@ def _compat_field_caps(client, fields, index=None):
# If the server version is 8.5.0 or later we don't need
# the query string work-around. Sending via any client
# version should be just fine.
if es_version(client) >= (8, 5, 0):
try:
elastic_version = es_version(client)
# If we lack sufficient permission to determine the Elasticsearch version,
# to be sure we use the workaround for versions smaller than 8.5.0
except elasticsearch.AuthorizationException as e:
raise RuntimeWarning(
"Couldn't determine Elasticsearch host's version. "
"Probably missing monitor/main permissions. "
"Continuing with the query string work-around. "
"Original exception: " + str(e)
bartbroere marked this conversation as resolved.
Show resolved Hide resolved
)
elastic_version = None
if elastic_version and elastic_version >= (8, 5, 0):
return client.field_caps(index=index, fields=fields)

# Otherwise we need to force sending via the query string.
Expand Down