N1QL query not returning results

@ryan.ym.tham

The primary index in an index on your WHOLE data set of just what keys are in your bucket. They are great index to use for prototyping your queries. But if you have a lot of keys in your bucket every-time you use the primary index the query service pulls all the data access the wire to find your data that your looking for. So your queries are probably timing out .

Adaptive Index
If you need a better “general” index you might want to use the adaptive index in CB 5.x.
The idea is that you might have a use case that you want to query by 10 to 100’s of elements in your JSON , but you don’t want to create indexes for all possible WHERE predicates. So its a trade off, adaptive indexes are not faster then a specific index , but it will give you more flexibility & fewer indexes to manage.
NOTE. Its not a all or nothing either you can have a mixer of both specific and adaptive indexes.
Docs on Adaptive indexes: Couchbase SDKs

Consolidating Indexes
Here is a forum post about general idea of consolidating indexes. Everybody want to do more with less :slight_smile: Query service : How it chooses the best index - #3 by househippo