Currently I have an index that looks like this:
[eventId-1, time1, true]
[eventId-1, time2, true]
[eventId-1, time3, true]
[eventId-1, time4, false]
[eventId-2, time5, true]
[eventId-2, time6, false]
[eventId-2, time7, true]
[eventId-1, time7, false]
Basically it is in the [eventId, created_at, type]
format.
Let’s say for eventId-1
, there are two type of docs identified by type
(true or false). I want to run a reduce function for eventId-1
with all the true type
of docs.
I have tried the following code but it doesn’t work:
Query query = app.getDatabase().getView("list").createQuery();
query.setDescending(true);
query.setStartKey(Arrays.asList(eventId, new HashMap<String, Object>(), false));
query.setEndKey(Arrays.asList(eventId, null, false));
query.setMapOnly(true);
QueryEnumerator result2 = query.run();
for (Iterator<QueryRow> it = result2; it.hasNext(); ) {
QueryRow row = it.next();
Log.d("MyApp", "Key is " + row.getKey());
}
I am getting nothing as output.
Can I query this with the current index or I need to create a new index where type
(true/false) is at the second position in the key array?