def author_search_by_id(self, dataset, aids): r = interface_pb2.EntityDetailRequest() r.dataset = dataset r.id.extend(aids) response = pbrequest(self.endpoint, "AuthorSearchById", r) er = interface_pb2.EntitySearchResponse() er.ParseFromString(response) return er
def _entity_search(self, method, query, offset, count): r = interface_pb2.EntitySearchRequest() r.dataset = "" r.query = query r.offset = offset r.count = count response = pbrequest(self.endpoint, method, r) er = interface_pb2.EntitySearchResponse() er.ParseFromString(response) return er
def pub_search(self, dataset, query, offset=0, count=20): r = interface_pb2.EntitySearchRequest() r.dataset = dataset r.query = query r.offset = offset r.count = count response = pbrequest(self.endpoint, "PubSearch", r) er = interface_pb2.EntitySearchResponse() er.ParseFromString(response) return er
def pub_search_by_author(self, dataset, author_id, offset=0, count=20): r = interface_pb2.EntitySearchRequest() r.dataset = dataset r.query = str(author_id) r.offset = offset r.count = count response = pbrequest(self.endpoint, "PubSearchByAuthor", r) er = interface_pb2.EntitySearchResponse() er.ParseFromString(response) return er
def jconf_search(self, dataset, query, offset=0, count=20): r = interface_pb2.EntitySearchRequest() r.dataset = dataset r.query = query r.offset = offset r.count = count response = pbrequest(self.endpoint, "JConfSearch", r) er = interface_pb2.EntitySearchResponse() er.query = query er.total_count = 0 return er
def _entity_detail_search(self, method, ids): self.entity_cache_lock.acquire() r = interface_pb2.EntityDetailRequest() er = interface_pb2.EntitySearchResponse() r.dataset = "" cached = [] for id in ids: if id not in self.entity_cache[method]: r.id.append(id) else: cached.append(id) if len(r.id): response = pbrequest(self.endpoint, method, r) er.ParseFromString(response) for e in er.entity: self.entity_cache[method][e.id] = e er.entity.extend([self.entity_cache[method][id] for id in cached]) self.entity_cache_lock.release() if er.total_count < len(er.entity): er.total_count = len(er.entity) return er