There seems to be a strange behaviour using QGIS expressions overlay_nearest() function with filter condition. The problem can be reduced to this minimal reproducible example (Geopackage with random point layer; see the comment to this answer for the larger context):
The idea is the find all features with the same name, using overlay_nearest(). To get the values in the attribute field result, I used this expression:
array_to_string(
with_variable (
'nname',
name,
eval('
overlay_nearest(
@layer,
name,
limit:=11,
filter:=name=''' || @nname || ''')
'))
)
It returns all features with the same name, including the current feature - so for id=4, it returns three times D as we have 3 feature with that value: 4, 5 and 7. This is the expected behaviour.
However, in the case of features with id= 0 or 1, it returns just one result. Playing around with the expression, it becomes clear that feature with id=0 only finds feature with id=1 and the other way round. So the first feature seems to be treated differently.
Why is that respectively: how to avoid that?
