I imagine I'm missing something really obvious here, but somehow I can't quite get it -- I'm using pyes to query an ElasticSearch endpoint pretty straightforwardly, so that I can then access the results by doing something like
print results.hits.hits._source.mets
and get a whole whack of JSON expressed as Python dicts, as expected:
{u'ns0:mets_list': [{u'@xmlns:ns0': u'http://www.loc.gov/METS/', u'@xmlns:ns3': u'http://hul.harvard.edu/ois/xml/ns/fits/fits_output', u'@xmlns:ns2': u'info:lc/xmlns/premis-v2', u'@xmlns:ns4': u'http://www.w3.org/1999/xlink', u'ns0:amdSec_list': [{u'ns0:techMD_list': [{u'ns0:mdWrap_list': [{u'@MDTYPE': u'PREMIS:OBJECT' ...
however, when I try to go a few levels deeper, I run across an issue: there are colons in some of the key names. I've tried every clever solution I can think of to escape these using various combinations of slashes and qutoes, but somehow, I can't quite figure it out, so I keep getting a syntax error on the colons:
print results.hits.hits[0]._source.mets.ns0:mets_list.ns0:fileSec_list
anyone mind pointing out the dumb thing I'm missing here? unfortunately I need to work with a slightly outdated version of pyes for this project so I haven't wanted to lean too heavily on current documentation, and while I have some knowledge of how unicode decoding normally works in Python, it's not revealing the simple solution.
thanks!
Perhaps the object you want is results.hits.hits[0]._source.mets[u'ns0:mets_list']
?