-
Notifications
You must be signed in to change notification settings - Fork 46
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
base: main
Are you sure you want to change the base?
Improve os read #1065
Conversation
@@ -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" |
There was a problem hiding this comment.
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:
sycamore/lib/sycamore/sycamore/transforms/explode.py
Lines 49 to 51 in 8471d43
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
sycamore/lib/sycamore/sycamore/tests/integration/connectors/opensearch/test_opensearch_read.py
Line 59 in 4b69ea9
def test_ingest_and_read(self, setup_index, exec_mode): |
No description provided.