lost data when use to_dict() to result
See original GitHub issue{
"_source": {
"base_info": {
"profile": null,
"name": null,
"headline": null,
"industry": null,
"avatar": null,
"email": "******@gmail.com",
"location": null
}
}
There is the data I have stored in ES and I can get them with RESTful API . The API returns me the full text .
When I get the doc use elasticsearch-dsl-py I also can get the data in search_result<response>
like this: {'location': None, 'name': None, 'avatar': None, 'industry': None, 'profile': None, 'headline': None, 'email': '*****@gmail.com'}
. But when I try to use result_list = [item.to_dict() for item in search_result]
I find the dict it returned is {'email': '******@gmail.com' }
and the items which values = None has gone away!
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Losing records when converting DataFrame to dictionary
Method 1: reviews = data.set_index('ID')['Reviews'].to_dict(). Method 2: Here we convert reviews to a list for each ID so that we don't lose ......
Read more >Using dictionaries to store data as key-value pairs
The dictionary stores objects as key-value pairs and can be used to represent complex real-world data.
Read more >to_dict_of_dicts — NetworkX 2.8.8 documentation
Returns adjacency representation of graph as a dictionary of dictionaries. Parameters: Ggraph. A NetworkX graph. nodelistlist. Use only nodes specified ...
Read more >pandas.DataFrame.to_dict — pandas 0.23.1 documentation
If you want a collections.defaultdict, you must pass it initialized. New in version 0.21.0. Returns: result : collections.Mapping like {column -> {index ...
Read more >Excel VBA Dictionary - A Complete Guide
Storing Multiple Values in One Key. Take a look at the sample data below. We want to store the Amount and Items for...
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
implemented in 0ee7feeadcc1fdcdb0817e5e0c6816c5f9cff728
I understand your issue. The reason why we decided to ignore those empty fields is:
tags
will return an empty list if not present on the document, accessingbody
would returnNone
.tags
on an empty document) and we don’t want those to then bloat the document and the indexthat said we could totally include a flag to control that behavior for when the data is shared with other systems that don’t have similar properties.