Calling from_es with returned hits from a Search
See original GitHub issueMy code:
MyDocType.from_es(Search(index='mydoctype').query('match', name=hit_name).execute().hits[0])
I see that the source for from_es uses the variable hit, so I assume it expects to be passed in a hit. This is apparently wrong since I get an attribute error; hit has no attribute copy()
.
Seems like this is a useful usecase (at least for me), is there a recommended way of doing this sort of thing? Would you be open to a MR to add that if not?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Green Day - Good Riddance (Time Of Your Life) [Official Music ...
Watch the official music video for Good Riddance (Time Of Your Life) by Green Day from the album Nimrod. Subscribe to...
Read more >c# - How can I find the method that called the current method?
Try this: using System.Diagnostics; // Get call stack StackTrace stackTrace = new StackTrace(); // Get calling method name Console.WriteLine(stackTrace.
Read more >BLAST QuickStart - Comparative Genomics - NCBI Bookshelf
The Basic Local Alignment Search Tool (BLAST) finds regions of local similarity between protein or nucleotide sequences. The program compares nucleotide or ...
Read more >Top 50 Love Songs of All Time - Billboard
The 50 best love songs of all time on the Billboard charts -- songs with "love" in the title that are the biggest...
Read more >Chapter 6 Extracting Values from Data Frames | Functions
If RStudio proposes the correct name (and here it does), then all we need to do is hit either tab or return. nrow(sec_class)....
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
I am wondering why you are doing this instead of just
MyDocType.search().query('match', name=hit_name).execute().hits[0]
which will already give you an instance ofMyDocType
?The
from_es
method is a low level method to construct the object from the raw dictionary, not the already pre-parsedHit
object. If you want to use it withHit
you will have to refer to the raw response by doing.execute().to_dict()['hits']['hits'][0]
Hope this helps!
The problem is that
ContactIndex
(or evenMyDocType
) is looking for index calledsome-alias
but the returning documents are tagged with the name of their actual index so it doesn’t match.The
_matches
classmethod needs to be implemented in that case, as per the example (0)Hope this helps!
0 - https://github.com/elastic/elasticsearch-dsl-py/blob/master/examples/alias_migration.py#L38-L42