Search returning Document
See original GitHub issueGiven a Doc that is a Document, I expected Doc.search()...
to return Docs rather than generic Hits, but this doesn’t seem to be the case. My goal is to dump a list of returned documents as JSON, and I would like to filter empty fields, just like doc.to_dict()
.
Is there a way to get the same behavior from Hit.to_dict() as Document.to_dict()? Is there a way to convert search responses into documents? Is there a more natural way to return search results as JSON, while filtering empty fields (including in nested documents)?
(This may all be related to #926. It’s possible that I’ve misconfigured doc_type.)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
ElasticSearch returns document in search but not in GET
This issue typically occurs when documents are indexed with non-default routing (either explicitly set or deducted from parent's id in case ...
Read more >How To Return All Documents From An Index In Elasticsearch
How To Return All Documents From An Index In Elasticsearch ... Use this option to search for all documents with the "nice" tag...
Read more >Search your data | Elasticsearch Guide [8.5] | Elastic
Documents that match a search's queries are returned in the hits, or search results, of the response. A search may also contain additional...
Read more >Simple Full-Text Search with ElasticSearch - Baeldung
Full-text search queries and performs linguistic searches against documents. It includes single or multiple words or phrases and returns ...
Read more >Search Documents (Azure Cognitive Search REST API)
Query an Azure Cognitive Search index and return search results.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hongyuan1306 definitely, have a look at the
alias_migration
example here - https://github.com/elastic/elasticsearch-dsl-py/blob/master/examples/alias_migration.py#L38-L42For the record (the script was edited since that reply), the magic happens in
BlogPost._matches
https://github.com/elastic/elasticsearch-dsl-py/blob/58c02732658018333cfd5fa2f7b70d942773b0be/examples/alias_migration.py#L60It is called from
elasticsearch_dsl.search.Request._get_result
https://github.com/elastic/elasticsearch-dsl-py/blob/58c02732658018333cfd5fa2f7b70d942773b0be/elasticsearch_dsl/search.py#L235