Commit 71a912b8 authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

wip

parent 3ddc6796152c
Pipeline #9854 failed with stages
in 32 seconds
......@@ -51,6 +51,7 @@ class IndexInES(Command):
schema = cnx.vreg.schema
# indexer = cnx.vreg['es'].select('indexer')
es = get_connection(cnx.vreg.config)
print('ohhhhhhhhhhhhhhh', es)
if es:
if self.config.etype:
etypes = (self.config.etype,)
......@@ -72,6 +73,9 @@ class IndexInES(Command):
def bulk_actions(self, etypes, cnx, dry_run=False):
for etype in etypes:
break
if etype in ('FAComponent', 'FindingAid', 'FAHeader', 'Did', 'IndexEntry'):
continue
rql = fulltext_indexable_rql(etype, cnx.vreg.schema)
rset = cnx.execute(rql)
if self.config.debug:
......@@ -89,6 +93,55 @@ class IndexInES(Command):
}
self.customize_data(data)
yield data
for data in self.facomponent_datas(cnx):
yield data
for data in self.findingaid_datas(cnx):
yield data
def facomponent_datas(self, cnx):
try:
digitized = {c for c, in cnx.execute('Any X WHERE X is FAComponent, EXISTS(X digitized_versions D)')}
rset = cnx.execute('''Any F,FD,FB,FA,FAR,FAI,DID,DUID,DT,DD,DM,DN,DO,DPD,DPL,DR,DSA,DSO,DA
WHERE F is FAComponent, F did DID,
F description FD, F bibliography FB, F abstract FA, F accessrestrict FAR, F acquisition_info FAI,
DID unitid DUID, DID unittitle DT, DID unitdate DD, DID materialspec DM, DID note DN, DID origination DO, DID physdesc DPD, DID physloc DPL, DID repository DR, DID startyear DSA, DID stopyear DSO, DID abstract DA''')
print('rset', len(rset))
for entity in rset.entities():
edata = entity.cw_attr_cache.copy()
did = entity.did[0]
edata.update(did.cw_attr_cache)
edata['digitized'] = entity.eid in digitized
data = {
'_op_type': 'index',
'_index': cnx.vreg.config['index-name'],
'_type': 'FAComponent',
'_id': entity.eid,
'_source': edata,
}
yield data
except Exception as e:
print('e', e)
def findingaid_datas(self, cnx):
rset = cnx.execute('''Any F,FN,FT,FD,FAI,FB,FK,DID,DUID,DT,DD,DM,DN,DO,DPD,DPL,DR,DSA,DSO,DA
WHERE F is FindingAid, F did DID,
F name FN, F fatype FT, F description FD, F acquisition_info FAI, F bibliography FB, F keywods FK,
DID unitid DUID, DID unittitle DT, DID unitdate DD, DID materialspec DM, DID note DN, DID origination DO, DID physdesc DPD, DID physloc DL, DID repository DR, DID startyear DSA, DID stopyear DSO, DID abstract DA''')
for entity in rset.entities():
edata = entity.cw_attr_cache.copy()
did = entity.did[0]
edata.update(did.cw_attr_cache)
data = {
'_op_type': 'index',
'_index': cnx.vreg.config['index-name'],
'_type': 'FAComponent',
'_id': entity.eid,
'_source': edata,
}
yield data
def customize_data(self, data):
pass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment