From ded92c578b9aed43085ce12b0d81084f8dc5acbc Mon Sep 17 00:00:00 2001 From: Larry Yan Date: Fri, 26 Jul 2019 13:54:15 +0800 Subject: [PATCH] fix(indexer): fix bug for indexer service dealing with empty doc --- gnes/service/indexer.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gnes/service/indexer.py b/gnes/service/indexer.py index 2c134cb1..9dcee602 100644 --- a/gnes/service/indexer.py +++ b/gnes/service/indexer.py @@ -36,15 +36,16 @@ def _handler_index(self, msg: 'gnes_pb2.Message'): weights = [] for d in msg.request.index.docs: - all_vecs.append(blob2array(d.chunk_embeddings)) - doc_ids += [d.doc_id] * len(d.chunks) - if msg.request.index.docs.doc_type == 'TEXT': - offsets += [c.offset_1d for c in d.chunks] - elif msg.request.index.docs.doc_type == 'IMAGE': - offsets += [c.offset_nd for c in d.chunks] - elif msg.request.index.docs.doc_type == 'VIDEO': - offsets += [c.offset_1d for c in d.chunks] - weights += [c.weight for c in d.chunks] + if d.chunks: + all_vecs.append(blob2array(d.chunk_embeddings)) + doc_ids += [d.doc_id] * len(d.chunks) + if msg.request.index.docs.doc_type == 'TEXT': + offsets += [c.offset_1d for c in d.chunks] + elif msg.request.index.docs.doc_type == 'IMAGE': + offsets += [c.offset_nd for c in d.chunks] + elif msg.request.index.docs.doc_type == 'VIDEO': + offsets += [c.offset_1d for c in d.chunks] + weights += [c.weight for c in d.chunks] from ..indexer.base import BaseVectorIndexer, BaseTextIndexer if isinstance(self._model, BaseVectorIndexer):