@@ -376,9 +376,14 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
376376
377377 outputs := make ([]* pb.Result , numGo )
378378 listType := schema .State ().IsList (q .Attr )
379+
380+ // These are certain special cases where we can get away with reading only the latest value
381+ // Lang doesn't work because we would be storing various different languages at various
382+ // time. So when we go to read the latest value, we might get a different language.
383+ // Similarly with DoCount and ExpandAll and Facets. List types are also not supported
384+ // because list is stored by time, and we combine all the list items at various timestamps.
379385 hasLang := schema .State ().HasLang (q .Attr )
380- getMultiplePosting := q .DoCount || q .ExpandAll || listType || hasLang
381- //getMultiplePosting := true
386+ getMultiplePosting := q .DoCount || q .ExpandAll || listType || hasLang || q .FacetParam != nil
382387
383388 calculate := func (start , end int ) error {
384389 x .AssertTrue (start % width == 0 )
@@ -399,7 +404,10 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
399404 fcs := & pb.FacetsList {FacetsList : make ([]* pb.Facets , 0 )} // TODO Figure out how it is stored
400405
401406 if ! getMultiplePosting {
402- pl , _ := qs .cache .GetSinglePosting (key )
407+ pl , err := qs .cache .GetSinglePosting (key )
408+ if err != nil {
409+ return err
410+ }
403411 if pl == nil || len (pl .Postings ) == 0 {
404412 out .UidMatrix = append (out .UidMatrix , & pb.List {})
405413 out .FacetMatrix = append (out .FacetMatrix , & pb.FacetsList {})
@@ -413,11 +421,6 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
413421 Tid : types .TypeID (p .ValType ),
414422 Value : p .Value ,
415423 }
416-
417- // TODO Apply facet tree before
418- if q .FacetParam != nil {
419- fcs .FacetsList = append (fcs .FacetsList , & pb.Facets {Facets : facets .CopyFacets (p .Facets , q .FacetParam )})
420- }
421424 }
422425 } else {
423426 pl , err := qs .cache .Get (key )
0 commit comments