You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Paul Milner <pa...@gmail.com> on 2022/10/01 12:56:49 UTC

Re: Multiple queries against a view

Hi Rene

Thanks for the answer. It was my misunderstanding of how to use the
multiple queries for the same view. It wasn't really clear to me from the
documentation that you do the following:


        var bulkQuery = {
            "queries": []
        }

            let query = {
                "key": "some key",
"skip": howeverymany,
"limit": whatever
            }

And then post bulkquery with multiple varying queries to the queries
endpoint.

But I figured it out eventually.

But thanks for replying anyway.

Paul



On Sat, 1 Oct 2022 at 01:36, Rene Veerman <
rene.veerman.netherlands@gmail.com> wrote:

> >I see it as a way to prevent concurrence when deleting items with
> multiple concurrent jobs.
>
> what's the initiator of this job? coz i can't figure out what the
> solution might really be here.
>
> On Sat, Oct 1, 2022 at 1:30 AM Rene Veerman <
> rene.veerman.netherlands@gmail.com> wrote:
>
> > alternately, you could use your own current db-access business logic
> > routines, and request each view result through javascript, then combine
> the
> > data in javascript.
> >
> > On Sat, Oct 1, 2022 at 1:28 AM Rene Veerman <
> > rene.veerman.netherlands@gmail.com> wrote:
> >
> >>
> >>
> https://github.com/NicerEnterprises/nicerapp/blob/main/NicerAppWebOS/apps/NicerAppWebOS/applications/2D/news/class.newsApp-3.php#L498
> >> has an example of multi-threaded curl in PHP, in this case to request
> >> 400+ RSS servers for their latest results, but you could easily run a
> >> couple of view queries with this as well.
> >>
> >> On Sat, Oct 1, 2022 at 1:26 AM Rene Veerman <
> >> rene.veerman.netherlands@gmail.com> wrote:
> >>
> >>> multi-threaded curl would seem the answer to this.
> >>> the view definition itself would enable a binary tree for the searches
> >>> to happen quickly, wouldn't it? <asking everyone here>
> >>>
> >>> On Sat, Sep 3, 2022 at 11:29 AM Paul Milner <pa...@gmail.com>
> >>> wrote:
> >>>
> >>>> Hello
> >>>>
> >>>> I'm looking to execute a view multiple times at once for different
> keys
> >>>> with different limits and skips (associated to each query). So I need
> >>>> the
> >>>> following:
> >>>>
> >>>> POST /recipes/_design/recipes/_view/by_title/queries
> >>>> HTTP/1.1Content-Type: application/jsonAccept: application/jsonHost:
> >>>> localhost:5984
> >>>> {    "queries": [        {            "keys": [
> >>>> "meatballs",                "spaghetti"            ]        },
> >>>> {            "limit": 3,            "skip": 2        }    ]}
> >>>>
> >>>> And I get the results object for each query. But can someone tell me
> >>>> how I form the queries object for multiple queries please? Something
> >>>> like:
> >>>>
> >>>> {    "queries": [
> >>>>
> >>>>         {            "keys": [                "meatballs",
> >>>>    "spaghetti"            ]        },        {            "limit": 3,
> >>>>           "skip": 2        },
> >>>>
> >>>>         {            "keys": [                "meatballs3",
> >>>>     "spaghetti3"            ]        },        {            "limit":
> >>>> 4,            "skip": 5        }
> >>>>
> >>>> ] }
> >>>>
> >>>>  or should this be done a different way? I'm only doing one key per
> >>>> view. So it's a way to execute a query multiple times in bulk with
> >>>> different limits and skips and get the array of results for each key.
> >>>> I'm looking to do the following:
> >>>>
> >>>> 1) Get the count of each key and use this to get a random item within
> >>>> the duplicates of the key.
> >>>>
> >>>> 2) Delete a random item with the duplicates of the key.
> >>>>
> >>>> I see it as a way to prevent concurrence when deleting items with
> >>>> multiple concurrent jobs.
> >>>>
> >>>> I hope that's clear.
> >>>>
> >>>> Thanks a lot
> >>>>
> >>>> Best regards
> >>>>
> >>>> Paul
> >>>>
> >>>
>