Skip to content

Commit

Permalink
Fix unrecongnized parameter 'include_type_name'
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyb1992 authored Dec 9, 2019
1 parent 7e48514 commit 7b4cf41
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion es_pandas/es_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,16 @@ def to_pandas(self, index, query_rule={'query': {'match_all': {}}}, heads=[], dt
count = self.es.count(index=index, body=query_rule)['count']
if count < 0:
raise Exception('Empty for %s' % index)
mapping = self.ic.get_mapping(index=index, include_type_name=False)
if self.es7:
mapping = self.ic.get_mapping(index=index, include_type_name=False)
else:
# Fix es client unrecongnized parameter 'include_type_name' bug for es 6.x
mapping = self.ic.get_mapping(index=index)
keys = list(mapping[index]['mappings'].keys())
if len(keys) > 2: raise Exception('Multi templates exits: %s' % (','.join(keys)))
tmp = mapping[index]['mappings'][keys[1]]['properties']
del mapping[index]['mappings'][keys[1]]
mapping[index]['mappings']['properties'] = tmp
if len(heads) < 1:
heads = [k for k in mapping[index]['mappings']['properties'].keys()]
else:
Expand Down

0 comments on commit 7b4cf41

Please sign in to comment.