Revision 47298
Added by Sandro La Bruzzo almost 7 years ago
DLIESConnector.py | ||
---|---|---|
6 | 6 |
|
7 | 7 |
|
8 | 8 |
class DLIESConnector(object): |
9 |
def __init__(self, index_host, index_name='dli'): |
|
9 |
def __init__(self, index_host, index_name='dli_shadow'):
|
|
10 | 10 |
self.index_host = index_host |
11 | 11 |
self.client = Elasticsearch(hosts=[index_host]) |
12 | 12 |
self.index_name = index_name |
... | ... | |
28 | 28 |
args = {'linkprovider.name': value} |
29 | 29 |
return Q('nested', path='linkprovider', query=Q('bool', must=[Q('match', **args)])) |
30 | 30 |
|
31 |
def create_publisher_query(self, value): |
|
32 |
args = {'target.publisher.name': value} |
|
33 |
q = Q('nested', path='target.publisher', query=Q('bool', must=[Q('match', **args)])) |
|
34 |
return Q('nested', path='target', query=q) |
|
35 |
|
|
31 | 36 |
def list_datasources(self): |
32 | 37 |
search_object = Search(using=self.client, index=self.index_name).doc_type('scholix').query() |
33 | 38 |
search_object.aggs.bucket('all_datasources', 'nested', path='linkprovider').bucket('all_names', 'terms', |
... | ... | |
61 | 66 |
if 'creator' in inputObj: |
62 | 67 |
result.creators = [CreatorType(x.name) for x in inputObj.creator] |
63 | 68 |
if 'publisher' in inputObj: |
64 |
if len(inputObj.publisher.name) > 0: |
|
65 |
result.publisher = [DSType(inputObj.publisher.name)] |
|
69 |
publishers=[] |
|
70 |
for p in inputObj.publisher: |
|
71 |
publishers.append(p.name) |
|
72 |
result.publisher = publishers |
|
66 | 73 |
return result |
67 | 74 |
|
68 | 75 |
def convertScholix(self, response): |
... | ... | |
101 | 108 |
search_object = Search(using=self.client, index=self.index_name).doc_type('scholix').query( |
102 | 109 |
self.create_dataSource_query(datasource)) |
103 | 110 |
return self.convertScholix(search_object[page:page + 10].execute()) |
111 |
|
|
112 |
def realtionFromPublisher(self, publisher, page=0): |
|
113 |
search_object = Search(using=self.client, index=self.index_name).doc_type('scholix').query( |
|
114 |
self.create_publisher_query(publisher)) |
|
115 |
return self.convertScholix(search_object[page:page + 10].execute()) |
Also available in: Unified diff
added publisher to API