IAIndex.js - fix some issues with count when using a query