N1QL query not returning results

I tried to make queries from web portal in the Query Tab, but I’m not getting any results where there’s suppose to have document retrieved.

The query that I made is as simple as

SELECT ID FROM `APPLICATION where Type = ‘Person’

Tried to drop the primary index and create the same index again and now it works.

This is the second time it happens. Pls help and advice what might goes wrong.

@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 Server | Couchbase Docs

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