Skip to content

Commit

Permalink
Use the workaround if we can't determine the server's version (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartbroere authored Sep 15, 2023
1 parent eb69496 commit 5c5ef63
Showing 1 changed file with 14 additions and 1 deletion.
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: " + repr(e)
)
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

0 comments on commit 5c5ef63

Please sign in to comment.