Force n1ql to use an index

hi @vsr1,

I am creating an index like this:

CREATE INDEX ix111 ON bucket(app_uuid) WHERE (sub_type = “app”)

now, I would like to run a query just on the values from this index

something like:

SELECT app_uuid
FROM bucket USE INDEX (ix111)
ORDER by app_uuid
LIMIT 100

the query doesn’t want to use the index no matter if I add the sub_type = "app" as WHERE clause.

What I am doing wrong?

To Use Index query predicate must contain leading index key and subset of Index Condition

SELECT app_uuid
FROM bucket USE INDEX (ix111)
WHERE app_uuid IS NOT MISSING AND ( sub_type = “app”)
ORDER by app_uuid
LIMIT 100

1 Like