Skip to content

Commit

Permalink
fix loader
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Nov 12, 2024
1 parent 680f980 commit 7a3438f
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions tests/load_opensearch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,12 @@
}


def gendata(data):
"""
Generator function to yield features
"""

for f in data['features']:
try:
f['properties'][id_field] = int(f['properties'][id_field])
except ValueError:
f['properties'][id_field] = f['properties'][id_field]
yield {
"_index": index_name,
"_id": f['properties'][id_field],
"_source": f
}


# create index
os_.indices.create(
index=index_name, body=settings)
os_.indices.create(index=index_name, body=settings)

with open(sys.argv[1], encoding='utf-8') as fh:
d = json.load(fh)

for f in d['features']:
os_.index(index=index_name, body=f, id=f['properties']['id'],
os_.index(index=index_name, body=f, id=f['properties'][id_field],
refresh=True)

0 comments on commit 7a3438f

Please sign in to comment.