Congrats, you hit a true bug. :) I'll write it up.
It has to do with dictionaries. It would work fine if you were using
a list or array.
In the meantime, you can work around it with a static index.
public class Products_ByImageCount :
AbstractIndexCreationTask<Product>
{
public Products_ByImageCount()
{
Map = products => from product in products
select new
{
Images_Count = product.Images.Count()
};
}
}
_session.Query<Product, Products_ByImageCount>().Where(p =>
p.Images.Count == 0)
Note the parenthesis on the count, invoking the Enumerable.Count() in
the index map. The query still uses it without the parenthesis to
match the index field name.
And no, it doesn't work if you just add parenthesis to your original
query. That's part of the bug.