The following query looses the value of $avg-overall in the return clause when constructing XML:
for $product in collection("/db/products")/Product
let $avg-overall := avg($product/Reviews/Review/Overall)
order by $avg-overall descending
return
<x>{$avg-overall}</x>
returns the incorrect result:
<x/>
<x/>
However, the following query demonstrates that $avg-overall does have a value:
for $product in collection("/db/products")/Product
let $avg-overall := avg($product/Reviews/Review/Overall)
order by $avg-overall descending
return
$avg-overall
which returns the result:
5
5
An example input document looks like:
<Product>
<Reviews>
<Review>
<Overall>5</Overall>
</Review>
</Reviews>
</Product>
The index configuration looks like:
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index>
<range>
<create qname="Overall" type="xs:float"/>
</range>
</index>
</collection>
@adamretter Let me make sure I'm understanding something at the top of your post. Your FLWOR is supposed to return <x> elements but it actually returns <Reviews> elements?
@joewiz Ah no, oops. That's what happens when I try and simplify something quickly for a bug report. I have now fixed the example that I gave above.
I cannot reproduce the issue on current develop. The index configuration should definitely not make a difference as it won't be used here.
@adamretter Is this still affecting you with 3.4.0+?
i can't reproduce this on 4.0.0.
i get
<x>5</x>
@adamretter good to close?
@duncdrum I don't have the test data around anymore, so I guess we should just close it. Hopefully it is fixed.