I think I found the reason right after asking (facepalm), but it took me days to realize this.
I think fetch performs a naive "in" query, something like: q="userid:(123123 123123123 12432423321323)&rows={batchSize}" When userid to document relation is one-to-many, it is possible that above query will result in documents consisting entirely of last two userid's documents, so the first one is left out, resulting in empty username. Docs state that one to many is not supported with fetch, but I didn't stumble onto this issue until recently so I just assumed it would work. Sorry to take your time, I hope this helps somebody later. Have a nice day. On Wed, 14 Oct 2020 00:38:05 +0300 uyilmaz <uyil...@vivaldi.net.INVALID> wrote: > > Hi all, > > I have a streaming expression looking like: > > fetch( > myAlias, > top( > n=3, > ....various expressions here > sort="count(*) desc" > ), > fl="username", on="userid=userid", batchSize=3 > ) > > which fails to fetch username field for the 1st result: > > { > "result-set":{ > "docs":[{ > "userid":"123123", > "count(*)":58} > ,{ > "userid":"123123123", > "count(*)":32, > "username":"Ayha"} > ,{ > "userid":"12432423321323", > "count(*)":30, > "username":"MEHM"} > ,{ > "EOF":true, > "RESPONSE_TIME":34889}]}} > > But strangely, when I change n and batchSize both to 2 and touch nothing > else, fetch fetches the first username correctly: > > fetch( > myAlias, > top( > n=2, > ....various expressions here > sort="count(*) desc" > ), > fl="username", on="userid=userid", batchSize=2 > ) > > Result is: > > { > "result-set":{ > "docs":[{ > "userid":"123123", > "count(*)":58, > "username":"mura"} > ,{ > "userid":"123123123", > "count(*)":32, > "username":"Ayha"} > ,{ > "EOF":true, > "RESPONSE_TIME":34889}]}} > > What can be the problem? > > Regards > > ~~ufuk > > -- > uyilmaz <uyil...@vivaldi.net> -- uyilmaz <uyil...@vivaldi.net>