CREATE INDEX test1 ON mybucket(device.imei) WHERE (type = "devicestate");
select device.imei from mybucket
where device.imei = '015422000009356'
and type = "devicestate";
Thank you very much. For the reference, the following index worked
CREATE INDEX test2 ON mybucket(device.imei)
WHERE ((type = "devicestate") and ((device.imei) is not missing))
but without having “device.imei is not missing”, query engine cannot find the index.
Is this because of other document types that I have in the bucket? Why type = “devicestate” is not sufficient when all devicestate documents have device.imei value.
Index where clause doesn’t required ((device.imei) is not missing)).
Leading index key must be part of the query predicate because If leading index key is not part of the document indexer will not index that document. Unless query has predicate on leading index key the index will not chosen (query requesting the missing entries too)
CREATE INDEX test1 ON mybucket(device.imei) WHERE (type = "devicestate");
select device.imei from mybucket
where device.imei IS NOT MISSING
and type = "devicestate";