Does CouchDB support multiple range queries?

How are multiple range queries performed in CouchDB? For a condition of one range, the combination of startkey and endkey works fine, but the same thing does not work with the condition of multiple ranges.

My view function looks like this:

"function(doc){
       if ((doc['couchrest-type'] == 'Item') 
    && doc['loan_name']&& doc['loan_period']&&    
                      doc['loan_amount']) 
     {  emit([doc['template_id'],
          doc['loan_name'],doc['loan_period'],
           doc['loan_amount']],null);}}"

I need to get all documents using loan_period> 5 and loan_amount> 30000. The parameters of the start and end keys are as follows:

params = {:startkey =>["7446567e45dc5155353736cb3d6041c0",nil,5,30000],
  :endkey=>["7446567e45dc5155353736cb3d6041c0",{},{},{}],:include_docs => true}  

Here I do not get the desired result. I think my startkey and endkey options are wrong. Can anybody help me?

+5
source share
4 answers

A CouchDB view - . . , .

, loan_period , , , , loan_period, .

couchdb-lucene.

+4

. Couchdb , , .

. [1,'a',5] [1,'c',0] 1 1, 'a' 'c' , [1, 'a', 5] [1, 'a', 0]

, :

["7446567e45dc5155353736cb3d6041c0",nil,5,30000] ["7446567e45dc5155353736cb3d6041c0",nil,5,90000]

+1

. - (.. ), , .

:

emit( doc.index, [doc.name, doc.address, ....] );

.

, Couchdb , map/reduce. :

, ? ( )

0

CouchDB , , :

[template_id, loan_name, loan_period, loan_amount]

params = {:startkey =>["7446567e45dc5155353736cb3d6041c0",nil,5,30000],
  :endkey=>["7446567e45dc5155353736cb3d6041c0",{}],:include_docs => true}

or maybe

params = {:startkey =>["7446567e45dc5155353736cb3d6041c0","\u0000",5,30000],
  :endkey=>["7446567e45dc5155353736cb3d6041c0","\u9999",{}],:include_docs => true}
0
source

All Articles