Example #1
0
 def insert(self, keys: list, vectors: 'np.ndarray'):
     status, _ = self.client.insert(
         collection_name=self.collection_name,
         records=vectors,
         ids=keys)
     if not status.OK():
         self.logger.error('Insert failed: {}'.format(status))
         raise MilvusDBException(status.message)
Example #2
0
    def build_index(self, index_type: str, index_params: dict):
        type = self.get_index_type(index_type)

        self.logger.info(f'Creating index of type: {index_type} at'
                         f' Milvus Server. collection: {self.collection_name} with index params: {index_params}')
        status = self.milvus_client.create_index(self.collection_name, type, index_params)
        if not status.OK():
            self.logger.error('Creating index failed: {}'.format(status))
            raise MilvusDBException(status.message)
Example #3
0
 def search(self, query_vectors: 'np.ndarray', top_k: int, search_params: dict = None):
     self.logger.info(f'Querying collection: {self.collection_name} with search params: {search_params}')
     status, results = self.milvus_client.search(collection_name=self.collection_name,
                                                 query_records=query_vectors, top_k=top_k, params=search_params)
     if not status.OK():
         self.logger.error('Querying index failed: {}'.format(status))
         raise MilvusDBException(status.message)
     else:
         return results.distance_array, results.id_array