query view by multiple keys

57 views
Skip to first unread message

Alan Yang

unread,
Jul 28, 2015, 6:23:11 PM7/28/15
to LightCouch
HI comrades

Im very new to lightCouch and couchdb in gneral.. So i appologize if this question has already been aswered.. But i have done a seach with no success.. perhaps im not using the right terminology..

If i have documents like

car1{
    type: car
    color: blue
},
vam2{
    type: van
    colour: white
},
car3{
    type: car
    color: pink
}

and i wanted to find all cars or vans that are white how would i do this?

I created a view

[car, blue] - car1
[van, white] - vam2
[car, pink] - car3

List<String> keys = {"car, white", "van, white"}
whenever i quey view.keys(keys)

i get no results

if i query view.key("car", "white") that does work
I could run multiple queries for each one at a time ( view.key("car", "white"), view.key("van", "white")).. but then i have to worry about running 1000s or queries because there are 1000s of possible colours and vehicle types.. There is a keys method but maybe im not using a right syntax

Ahmed Yehia

unread,
Jul 28, 2015, 11:33:03 PM7/28/15
to light...@googlegroups.com
Hi,

The right method to query by key (or complex key) is view.key() 
Do you have matching documents in the database? I don't see a document for white car.
Maybe try to query the view in futon and verify the result with code. 



--
You received this message because you are subscribed to the Google Groups "LightCouch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lightcouch+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages