View returns duplicated key with a different value

Hi,

i was getting an unexpected count # from my frontend so I checked view from admin console.

I have a very simple view like this.

map:

function (doc, meta) {

    if (
        doc &&
        doc.entityType === 'activity' &&
        doc.clientId &&
        doc.target_id &&
        doc.target_form === 'user' &&
        doc.action === 'follow'
    )  {
        emit([doc.clientId, doc.target_id], null);
    }
}

reduce:
_count

When I query this view with 164 keys, I get a duplicate key with a different value.

For example, if I have [“testClient”, “testUser”] as one of my keys, I get

{"key":["testClient","testUser"],"value":28},
{"key":["testClient","testUser"],"value":132}

it’s not just one, there are many duplicated keys.

What’s interesting is that it does not happen if I use key() or keys() with only that particular key.

How do I fix this problem?

I’m one 4.1 EE

Hey @moon0326,

This definitely sounds odd, I did a hexdump of the keys to verify that they are indeed exactly the same (and not some weird hidden characters or anything) and they both return the same:

$ echo '["testClient","testUser"]' | hexdump
0000000 5b 22 74 65 73 74 43 6c 69 65 6e 74 22 2c 22 74
0000010 65 73 74 55 73 65 72 22 5d 0a
000001a

$ echo '["testClient","testUser"]' | hexdump
0000000 5b 22 74 65 73 74 43 6c 69 65 6e 74 22 2c 22 74
0000010 65 73 74 55 73 65 72 22 5d 0a
000001a

I would like to try and reproduce this locally, is the data sensitive, I guessed from the ‘testClient’, ‘testUser’ that this is test data?
If possible could you please post the full output of your query with 164 keys please?
Perhaps you could also provide a backup (see cbbackup) file of the dataset, otherwise I will try and create my own dataset to reproduce the problem, although this will take a little longer.
Additionally are you querying the view from an SDK, the syntax used to do so would be very helpful too, as well as the ‘value’ of the result when you just use key() with that single key!