아래 내용이 정확합니까 아니면 다른 내용이어야합니까?
이것이 개별 (중첩 된) 필드에 액세스하는 가장 효율적인 방법인지 확인하는 것만으로도 예상되는 결과를 얻고 있습니다.
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']
execute
수동으로 호출 할 필요가 없으며 []
이름으로 필드에 액세스하는 데 사용할 필요가 없습니다 . 속성 액세스를 사용하면됩니다.
for hit in s:
print hit.policyNumber
print hit.party[0].fullName
print hit.party[0].partyAddress[0].address1
print hit.party[0].partyAddress[0].city
print hit.party[0].phoneList[0].phoneNumber
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다