Revision 58542
Added by Sandro La Bruzzo almost 4 years ago
es_connector.py | ||
---|---|---|
5 | 5 |
from elasticsearch_dsl import * |
6 | 6 |
import logging |
7 | 7 |
from eu.dnetlib.util import get_index_properties |
8 |
import traceback |
|
8 | 9 |
|
9 | 10 |
import os |
10 | 11 |
from os import path |
... | ... | |
198 | 199 |
s = s[start:end] |
199 | 200 |
response = s.execute() |
200 | 201 |
|
201 |
print (response.hits.total) |
|
202 |
|
|
202 | 203 |
|
203 | 204 |
hits = [] |
204 | 205 |
|
205 | 206 |
for index_result in response.hits: |
206 | 207 |
input_source = index_result.__dict__['_d_'] |
208 |
|
|
207 | 209 |
fixed_titles = [] |
208 | 210 |
|
209 | 211 |
for ids in input_source.get('localIdentifier', []): |
... | ... | |
268 | 270 |
return |
269 | 271 |
relSource = relation.get('source') |
270 | 272 |
collectedFrom = relSource.get('collectedFrom',[]) |
271 |
for coll in collectedFrom: |
|
272 |
for d in source['datasources']: |
|
273 |
if d['datasourceName'] == coll['provider']['name']: |
|
274 |
d['provisionMode'] = coll['provisionMode'] |
|
273 |
if collectedFrom is not None: |
|
274 |
for coll in collectedFrom: |
|
275 |
for d in source['datasources']: |
|
276 |
if d['datasourceName'] == coll['provider']['name']: |
|
277 |
d['provisionMode'] = coll['provisionMode'] |
|
275 | 278 |
return source |
276 | 279 |
|
277 | 280 |
def item_by_id(self, id, type=None, start=None): |
278 | 281 |
try: |
279 |
res = self.client.get(index=self.index_name+"_object", id=id)
|
|
282 |
res = self.client.get(index=self.index_name+"_object",doc_type="_all", id=id, _source=True)
|
|
280 | 283 |
hits = [] |
281 | 284 |
input_source = res['_source'] |
282 | 285 |
fixed_titles = [] |
... | ... | |
324 | 327 |
related_unknown=related_unknown)) |
325 | 328 |
|
326 | 329 |
return DLIESResponse(total=1, hits=hits) |
327 |
except Exception as e: |
|
330 |
except Exception as e:
|
|
328 | 331 |
log.error("Error on getting item ") |
329 |
log.error(e) |
|
332 |
log.error(e)
|
|
330 | 333 |
#log.error("on line %i" % sys.exc_info) |
331 | 334 |
return DLIESResponse() |
Also available in: Unified diff
fixed npe