Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map/Reduce query not working on partitioned non-replicated database #8405

Closed
Karalix opened this issue Nov 4, 2021 · 6 comments · May be fixed by #8611
Closed

Map/Reduce query not working on partitioned non-replicated database #8405

Karalix opened this issue Nov 4, 2021 · 6 comments · May be fixed by #8611
Labels

Comments

@Karalix
Copy link

Karalix commented Nov 4, 2021

Issue

I have a partitioned database on my CouchDB server. I access it by giving its URL to the PouchDB constructor so PouchDB is acting only as a client. Although everything seems to work fine, when I try to use the query method to execute a view from my design document :

pouch.query('events/dates',{
     startkey: todaybegin,
     endkey: tomorrowbegin,
     include_docs: true
})

I get the following error :

{
name: "query_parse_error",
reason: "`partition` parameter is mandatory for queries to this view.",
status: 400
}

I was a bit surprised because this error did not show up with a locally replicated database during my previous work with PouchDB. But well, it makes sense since nano has a specific method for partitioned db and when dealing with CouchDB API directly, it also always require the partition name in the following form http://127.0.0.1:5984/databasename/_partition/event/_design/events/_view/dates

I can't find anywhere in the docs if there is an existing parameter so I can pass to set the name of the partition.

Info

  • Environment: Browser
  • Platform: Firefox 94
  • Adapter: IndexedDB
  • Server: CouchDB 3.2
@dheimoz
Copy link

dheimoz commented Dec 4, 2021

hey @Karalix
Would you mind sharing the specifics for your partitions?

I assume they are "todaybegin:IDENTIFIER"?

@Karalix
Copy link
Author

Karalix commented Dec 5, 2021

Sure, they are typicaly in the form event:fhg45F or resource-fhg45F:kj45P7, nothing very exotic there.

And one the views I am trying to use is formatted like this:

{
  "_id": "_design/events",
  "_rev": "1-9deb72b6aa08e62e8618a2426833f64e",
  "views": {
    [...]
    "tag-list": {
      "reduce": "_count",
      "map": "function (doc) {\n  if (doc.tags && doc.tags.length > 0) {\n    for (const tag of doc.tags) {\n      emit(tag, 1)\n    }\n  }\n}"
    }
  },
  "language": "javascript",
  "options": {
    "partitioned": true
  }
}

@dheimoz
Copy link

dheimoz commented Dec 5, 2021

hey @Karalix , thanks for the feedback. I truly believe that Pouchdb API has not catch up the partition db that Couchdb has. I used nano in Node.js seamlessly but haven't had the need with Pouchdb. Let me give it a try based on my node.js project.

@github-actions
Copy link

github-actions bot commented Feb 4, 2022

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@rizwan92
Copy link

i am also facing the same issue why pouch DB is not supporting partitioned feature

@lucidNTR
Copy link
Contributor

i made a pr for this, the issue has been closed accidentally by the stale bot. if a maintainer sees this, pls consider reopening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants