我正在尝试在python中学习const personData = { personList: [ { personCodes: [ { code: "001", desc: "Indian" } ] }, { personCodes: [ { code: "002", desc: "Spanish" } ] }, { personCodes: [ { code: "001", desc: "Spanish" }, { code: "002", desc: "Spanish1" }, { code: "003", desc: "Spanish2" } ] }, { personCodes: [ { code: "001", desc: "Russian" } ] }, { personCodes: [ { code: "001", desc: "Spanish" }, { code: "002", desc: "Indian" }, { code: "004", desc: "Japanina" } ] }, { personCodes: [ { code: "001", desc: "Spanish" }, { code: "004", desc: "Indian" }, { code: "003", desc: "Japanina" } ] }, ] };
const personID = ["001","003"];
const result = personData.personList.filter(role =>
role.personCodes && personID.every(x =>
role.personCodes.find(a => x.includes(a.code))
));
console.log(result);
模块,{elasticsearch
)我试图在Python Elasticsearch上关注他们的文档,这是他们网站上的代码:
pip3 install elasticsearch
我收到此错误from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()
doc = {
'author': 'kimchy',
'text': 'Elasticsearch: cool. bonsai cool.',
'timestamp': datetime.now(),
}
res = es.index(index="test-index", doc_type='tweet', id=1, body=doc)
print(res['result'])
,该模块是否已弃用?