-
Notifications
You must be signed in to change notification settings - Fork 24
Elasticsearch 'fields' parameter not usable in similarity_search* methods #64
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,11 +69,14 @@ def _hits_to_docs_scores( | |
|
||
documents = [] | ||
|
||
def default_doc_builder(hit: Dict) -> Document: | ||
return Document( | ||
def default_doc_builder(hit: Dict, fields: List[str]) -> Document: | ||
doc = Document( | ||
page_content=hit["_source"].get(content_field, ""), | ||
metadata=hit["_source"].get("metadata", {}), | ||
) | ||
for field_key in fields: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines (84-88) (now 87-91) do exactly that, wouldn't those lines (80-88) get removed then? Maybe there are other instances in which people create more sophisticated document builders and the fields should be added anyway as they are being added in those lines. In my current code I just made the changes from above and everything works as expected without any changes in this file. Maybe the maintainers can have a look at this. |
||
doc.metadata[field_key] = hit["_source"].get(field_key, None) | ||
return doc | ||
|
||
doc_builder = doc_builder or default_doc_builder | ||
|
||
|
@@ -87,7 +90,7 @@ def default_doc_builder(hit: Dict) -> Document: | |
]: | ||
hit["_source"]["metadata"][field] = hit["_source"][field] | ||
|
||
doc = doc_builder(hit) | ||
doc = doc_builder(hit, fields) | ||
documents.append((doc, hit["_score"])) | ||
|
||
return documents | ||
|
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.
There's still a random indent here.