Hi!
I tried to use a secondary index in the following scenario.
There are documents of type ‘car’, with a property ‘price’, e.g.:
conn.set(key='foobar_car', value='{'type': 'car', 'price': 1000}')
I created a view to query the car documents based on the prices:
function (doc, meta) {
if (doc.type == "car" && doc.price) {
emit([doc.price], null);
}
}
Now I want to use the View to query the cars that have a price between 0 and 1000.
myView.iterate(mapkey_range=[[0], [1000]], reduce=False, stale=False)
This works fine as long as a price of a car does not change, i.e., if I update the price of a car, the query appears to not take this into account, even if I use stale=False. A workaround would be to do the filtering on the client side, but I don’t really like that.
Is this really the intended View behavior? Looking at the documentation, it was not clear to me if the map function is called once per every document, or once per every document change.
Many Thanks!