Skip to content

Commit 06bfb60

Browse files
committed
add CRUD to ES plugin
1 parent 3aa669b commit 06bfb60

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pycsw/plugins/repository/elastic.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def describe(self) -> dict:
149149

150150
return properties
151151

152-
def dataset(self, record):
152+
def dataset(self, record={}):
153153
"""
154154
Stub to mock a pycsw dataset object for Transactions
155155
"""
@@ -317,6 +317,21 @@ def query(self, constraint=None, sortby=None, typenames=None,
317317

318318
return total, results
319319

320+
def insert(self, record, source, insert_date):
321+
item = json.loads(record.metadata)
322+
LOGGER.debug(f"Inserting/updating item with identifier {item['id']}")
323+
_ = self.es.index(index=self.index_name, id=item['id'], body=item)
324+
LOGGER.debug('Item added')
325+
326+
return item['id']
327+
328+
def update(self, record=None, recprops=None, constraint=None):
329+
self.insert(record, None, None)
330+
331+
def delete(self, constraint):
332+
LOGGER.debug(f"Deleting item with {constraint['values'][0]}")
333+
_ = self.es.delete(index=self.index_name, id=constraint['values'][0])
334+
320335
def _doc2record(self, doc: dict):
321336
"""
322337
Transform a Solr doc into a pycsw dataset object

0 commit comments

Comments
 (0)