lucene icon indicating copy to clipboard operation
lucene copied to clipboard

ToParentBlockJoinSortField does not handle missing values correctly

Open romseygeek opened this issue 10 months ago • 3 comments

Description

I realised that as part of #15483 I'd made it impossible to set a missing value on ToParentBlockJoinSortField, so set about adding the functionality back in and adding some tests. This showed pretty quickly that the missing value functionality here doesn't really work in the way I'd expect.

The idea of this sort field is that you query parent documents, but order them by the 'best' value of their children. So a missing value should by rights be applied to a child document that doesn't have a value, as it's the children's values that are being used for ordering. However, what actually happens is that the missing value is used for parent documents that have either no children at all, or only children without sort values.

I think we should change this so that the missing value is propagated to the child sorters.

Version and environment details

No response

romseygeek avatar Jan 05 '26 10:01 romseygeek

I would like to work on this. I plan to update ToParentBlockJoinSortField to ensure the missingValue is properly propagated down to the child document comparators. This will allow the missing value logic to apply to children before aggregation, rather than just to the parent.

ML-dev-crypto avatar Jan 16 '26 19:01 ML-dev-crypto

I would also like to give it a try, I will take a look coming week, @ML-dev-crypto if you have already made some progress on it let me know.

gmarouli avatar Feb 13 '26 11:02 gmarouli

First let's identify what we want to achieve here:

  1. Introduce configurable missingValue one for parent level and one for child level, just like we have the two sorting order configurations.
  2. Expand the "missing" scenarios to also be able to identify when a parent has children with missing values and use the child missing value there.

Missing value usage scenarios

  • When a parent has no children, then we use the parentMissingValue.
  • When a child does not have the sorting field, then we use the childMissingValue when sorting the parent.

gmarouli avatar Feb 18 '26 11:02 gmarouli