diff --git a/worker/task.go b/worker/task.go index d2407b9a551..e773f5e318c 100644 --- a/worker/task.go +++ b/worker/task.go @@ -384,7 +384,11 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er vals, fcs, err := retrieveValuesAndFacets(args, pl, listType) switch { - case err == posting.ErrNoValue || len(vals) == 0: + case err == posting.ErrNoValue || (err == nil && len(vals) == 0): + // This branch is taken when the value does not exist in the pl or + // the number of values retreived is zero (there could still be facets). + // We add empty lists to the UidMatrix, FaceMatrix, ValueMatrix and + // LangMatrix so that all these data structure have predicatble layouts. out.UidMatrix = append(out.UidMatrix, &pb.List{}) out.FacetMatrix = append(out.FacetMatrix, &pb.FacetsList{}) if q.DoCount {