Weird behaviour with query builder and indexes

Markus Halttunen shared this question 6 years ago
Answered

I had this kind of a query (overly simplified):

db.eventLog.aggregate().match(qb.where("details.className").eq("MyEvent")).count()

I had an index for "details.className" but the query was not hitting it. It was performing a collection scan. When I changed the query like this:

db.eventLog.aggregate().match(qb.where("details.className").eq("MyEvent").build()).count()

It started to work. However, even the first query was producing correct results - it was just very slow. What could explain this?

Replies (1)

photo
1

Thank you for you feedback. It 's a serious bug.

We have worked out a hotfix 4.6.1 to resolve the issue. Please download and give it a try.

db.eventLog.aggregate().match(qb.where("details.className").eq("MyEvent")).count()// it should works.
https://www.nosqlbooster.com/downloads

Leave a Comment
 
Attach a file