So, the way you design views is to identify what you’re going to search for – states – and then emit those as the keys in the index. In this case each doc contains multiple states, so you’d loop over the “states” array and emit each string as a key.
Then in the query you are looking for the rows with a specific key – “CA” – so you set that as both the startKey and endKey. Alternatively you could set the query’s keys property to an array containing only “CA”.
You almost never stick a specific query value like “CA” into the map function, because then you have a view that’s only good for that one query, which is a waste.
Hi @jens implementation above is clear and it works…but I have another question for this topic…Is it possible to return more that one key in map function? Actually I want to achieve "LIKE " query from SQL… for example if user type “cu” it should search type and name from example above…