0
votes

i am trying to filter records using key.For example

localhost:5984/school/_design/school/_view/schoolstats?startkey=[Name,DOB,AGE]&endkey=[Name,DOB,AGE]

1)filter using Name only 2)filter using Name and Age only 3)filter using Name and DOB only 4)filter using Age only

I have tried a lot using wildcard in couchdb but cant able to fetch the exact result.

2

2 Answers

1
votes

If you use a ranged query with startkey and endkey, the order of keys is not changeable.

These combination should be working. If you need other combination you have to emit your multikey in the desired form.

startkey=[Name]&endkey=[Name,{}]
startkey=[Name,DOB]&endkey=[Name,{}]
startkey=[Name,DOB,AGE]&endkey=[Name,{}]
startkey=[Name,DOB]&endkey=[Name,DOB,{}]

For your asked filters, you have to emit two more keys/multikeys in your map function.

0
votes

I think, if you do not change your emitting keys, aka, you have a emitting statement like: emit [Name,DOB,AGE], null

1)Filter using Name only

startkey=[Name]&endkey=[Name,{}]

2)Filter using Name and Age only

Can not

3)Filter using Name and DOB only

startkey=[Name,DOB]&endkey=[Name,DOB,{}]

4)Filter using Age only

Can not