Dynamic Key in CBL view


We are having a peculiar case where One Person moves from one state to other. So in mapper we are emitting who is in which state. Following is how we are emitting documents

The data in the CBL key will look like as follows:-
but now when the User moves to other state say State2 the key will be emitted as

Now if I see people in State 1 on 2017-07-24 date then I will see 1 count and on state 2 I will see 1 count.
But the actual count is 0,1 for state-1 and stat-2 respectively.

Can you suggest how older key can get replaced by the new key. Or what should be the design of emitted key.

Pankaj Sharma

Question 1:- If I call UpdateIndex function will it delete older key if its not emitted again.
Question 2 What DeleteIndex does, Will it help deleting a key?

You started another thread about deleting keys, so let’s use that instead.
In general, I think you’re misunderstanding how views work, since a key isn’t something you can delete.