Hi Ronan,

When using pouchdb-find are you querying a CouchDB backend or using
PouchDB?
The reason that adding "_id": {"$gt": 0} works is because
pouchdb-find/mango fetches all the docs using the _all_docs index and then
processes the $in operator in memory.
We have added functionality that the $in operator should work without
needing the "_id": {"$gt": 0} selector. So if it didn't work that means
there is a bug in pouchdb-find. I have written a blogpost on how
pouchdb-find/mango actually works and it might help you understand what is
actually happening [1].

Cheers
Garren

[1]
http://www.redcometlabs.com/blog/2015/12/1/a-look-under-the-covers-of-pouchdb-find




On Fri, Jan 20, 2017 at 11:21 PM, Ronan Jouchet <
[email protected]> wrote:

> Hi, this is a mailing-list repost of StackOverflow question
> "pouchdb-find: can $in / $or queries use indexes?" [1]
>
> I noticed that queries using $in, such as:
>
>     "type": {"$in": ["a", "b"]}
>
> ... fail to use the existing relevant index (pouchdb-find warns
> "no matching index found, create an index to optimize query time").
> StackOverflow user markwatsonatx suggested adding to my query
>
>     "_id": {"$gt": 0}
>
> ... and indeed I no longer get index warnings with it.
>
> Is this expected behavior? Can anyone explain what's going on? Thanks!
>
> [1] http://stackoverflow.com/questions/40686383/pouchdb-find-
> can-in-or-queries-use-indexes
>

Reply via email to