class GraphQLTestIndexer(Executor): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._docs = DocumentArray() @requests(on='/index') def index(self, docs: DocumentArray, **kwargs): self._docs.extend(docs) @requests(on='/search') def process(self, docs: DocumentArray, parameters: Dict, **kwargs): limit = int(parameters.get('limit', 2)) docs.match(self._docs, limit=limit) @requests(on='/foo') def foo(self, docs: DocumentArray, **kwargs): docs[0].text = 'foo' @requests(on='/bar') def bar(self, docs: DocumentArray, **kwargs): docs[0].text = 'bar' @requests(on='/target-exec') def target_exec(self, docs: DocumentArray, **kwargs): docs[0].text = 'Indexer'
def embed(self, docs: DocumentArray, **kwargs): docs.embeddings = np.random.random([len(docs), 10]).astype(np.float32)
def process(self, docs: DocumentArray, parameters: Dict, **kwargs): limit = int(parameters.get('limit', 2)) docs.match(self._docs, limit=limit)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._docs = DocumentArray()