以下是准确的还是应该是其他的?
我得到了预期的结果,只是检查这是否是访问单个(嵌套)字段的最有效方式。
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search, Q
import json
client = Elasticsearch('my_server')
policy_number = 'POLICY1234'
s = Search(using=client, index = "my_index").query("term",policyNumber=policy_number.lower())
es_response = s.execute()
for hits in es_response:
print hits['policyNumber']
print hits.party[0]['fullName']
print hits.party[0].partyAddress[0]['address1']
print hits.party[0].partyAddress[0]['city']
print hits.party[0].phoneList[0]['phoneNumber']