Hi
We have document which has an attribute status, the initial value of this status would be PENDING. Later after some batch job runs the status gets updated to SUCCESS or ERROR.
We have following indexes created to retreive the counts based on status,
CREATE INDEX legacy_createdDateTime_class_status_pending_reqDuplicated_false ON promotions
(createdDateTime
) PARTITION BY HASH(META().Id)
WHERE _class
= ‘XXXXXX’ AND status
= ‘PENDING’ AND requestDuplicated
= false
using GSI WITH {“num_replica”: 1,“num_partition”:6} ;
CREATE INDEX legacy_createdDateTime_class_status_success_reqDuplicated_false ON promotions
(createdDateTime
) PARTITION BY HASH(META().Id)
WHERE _class
= ‘XXXXXX’ AND status
= ‘SUCCESS’ AND requestDuplicated
= false
using GSI WITH {“num_replica”: 1,“num_partition”:6} ;
CREATE INDEX legacy_createdDateTime_class_status_error_reqDuplicated_false ON promotions
(createdDateTime
) PARTITION BY HASH(META().Id)
WHERE _class
= ‘XXXXXX’ AND status
= ‘ERROR’ AND requestDuplicated
= false
using GSI WITH {“num_replica”: 1,“num_partition”:6} ;
As an example,
if there are 100 PENDING documents,
out of which 95 became SUCCESS,
5 became ERROR.
When executing n1ql query the count of SUCCESS AND ERROR documents are coming correctly with 95 and 5 respectively. But when executing n1ql count query for PENDING it shows 100 rather than 0. Looks like the index is not getting update. Any help on this would be appreciated.
Count query:
SELECT count(*) FROM promotions commandStatus WHERE _class
= “XXXXXX”
AND commandStatus.status = “SUCCESS” (or PENDING or ERROR)
AND commandStatus.requestDuplicated = false
AND commandStatus.createdDateTime BETWEEN 1579478400000 AND 1580428800000
Regards,
Venkat