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

Stringify doc[id] field #3015

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions connectors/es/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ async def get_docs(self, generator, skip_unchanged_documents=False):
if count % self.display_every == 0:
self._log_progress()

doc_id = doc["id"] = doc.pop("_id")
doc_id = doc.pop("_id")
doc["id"] = str(doc_id)

if self.basic_rule_engine and not self.basic_rule_engine.should_ingest(
doc
Expand Down Expand Up @@ -660,7 +661,8 @@ async def get_docs_incrementally(self, generator):
if count % self.display_every == 0:
self._log_progress()

doc_id = doc["id"] = doc.pop("_id")
doc_id = doc.pop("_id")
doc["id"] = str(doc_id)

if self.basic_rule_engine and not self.basic_rule_engine.should_ingest(
doc
Expand Down Expand Up @@ -737,7 +739,8 @@ async def get_access_control_docs(self, generator):
if count % self.display_every == 0:
self._log_progress()

doc_id = doc["id"] = doc.pop("_id")
doc_id = doc.pop("_id")
doc["id"] = str(doc_id)
doc_exists = doc_id in existing_ids

if doc_exists:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,17 @@ async def _dl(doit=True, timestamp=None):
def index_operation(doc):
# deepcopy as get_docs mutates docs
doc_copy = deepcopy(doc)
doc_id = doc_copy["id"] = doc_copy.pop("_id")
doc_id = doc_copy.pop("_id")
doc_copy["id"] = str(doc_id)

return {"_op_type": "index", "_index": INDEX, "_id": doc_id, "doc": doc_copy}


def update_operation(doc):
# deepcopy as get_docs mutates docs
doc_copy = deepcopy(doc)
doc_id = doc_copy["id"] = doc_copy.pop("_id")
doc_id = doc_copy.pop("_id")
doc_copy["id"] = str(doc_id)

return {"_op_type": "update", "_index": INDEX, "_id": doc_id, "doc": doc_copy}

Expand Down
Loading