couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Ellis <RICEL...@uk.ibm.com>
Subject Re: Multiple queries at the same time against a view
Date Fri, 23 Oct 2020 12:45:06 GMT
Hi Paul,

I think the problem you are seeing is related to using both reduce and 
skip. Reduce is true by default when there is a reduce function present in 
the view. I think you are, in effect, skipping past the [single] row with 
the reduced result for your given key (you could validate this by setting 
"skip":0).

I suspect you probably want to add `reduce: false` to each query.

Hope that helps,
Rich



From:   Paul Milner <pauljmilner@gmail.com>
To:     user@couchdb.apache.org
Date:   23/10/2020 13:03
Subject:        [EXTERNAL] Multiple queries at the same time against a 
view



Hello Everybody

I am trying to run multiple queries against a view at the same time using
the queries endpoint.

post to db/_design/designdoc/_view/viewcount/queries

I need different limits and skips on each query.

I post the following data:

{
   "queries":[
      {
         "key":"key1",
         "limit":3,
         "skip":1
      },
      {
         "key":"key2",
         "limit":1,
         "skip":2
      },
      {
         "key":"key3",
         "limit":4,
         "skip":0
      },
      {
         "key":"key4",
         "limit":1,
         "skip":3
      },
      {
         "key":"key5",
         "limit":2,
         "skip":1
      },
      {
         "key":"key6",
         "limit":3,
         "skip":4
      }
   ]
}

My view is as follows:

function(doc){
  emit(doc.key, 1);
}

with a _count reduce function.

The response I get is:

status":200,"text":"{\"results\":[\r\n{\"rows\":[\r\n\r\n]},\r\n{\"rows\":[\r\n\r\n]},\r\n{\"rows\":[\r\n\r\n]},\r\n{\"rows\":[\r\n\r\n]},\r\n{\"rows\":[\r\n\r\n]},\r\n{\"rows\":[\r\n\r\n]}\r\n]}\n"}

I have looked at the following documentation, but sorry it's not very 
clear
to me:

https://docs.couchdb.org/en/stable/api/ddoc/views.html#api-ddoc-view-multiple-queries 


Can someone tell me how to formulate this request correctly please?

Thank you
Best regards
Paul



Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Mime
View raw message