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

Improve os read #1065

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Improve os read #1065

wants to merge 2 commits into from

Conversation

austintlee
Copy link
Contributor

No description provided.

@@ -47,6 +48,9 @@ def read_records(self, query_params: BaseDBReader.QueryParams) -> "OpenSearchRea
if "size" not in query_params.query and "size" not in query_params.kwargs:
query_params.kwargs["size"] = 200
result = []
# We only fetch the minimum required fields for full document retrieval/reconstruction
if query_params.reconstruct_document:
query_params.kwargs["_source_includes"] = "doc_id,parent_id,properties"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked into only fetching "parent_id", but the problem with only getting child documents here is that we also need parent docs (which do not have "parent_id") and their properties as during explode() we do not transfer all properties from parent to child docs:

for doc_property in parent.properties.keys():
if doc_property.startswith("_"):
cur.properties[doc_property] = parent.properties[doc_property]

Otherwise, we would have to make another round of calls to OpenSearch just to fetch parent docs which may be less efficient and more time consuming than just fetching doc_id, parent_id and properties here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you need properties. At least in my testing; I was getting parent ids in the _id field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need to reconstruct all of the properties? If that is the case, I think we can just reconstruct using only the child elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the test I ran to verify correctness:

def test_ingest_and_read(self, setup_index, exec_mode):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants