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

Search drilldown fails with multiple parameters #148

Open
glynnbird opened this issue Mar 15, 2019 · 1 comment
Open

Search drilldown fails with multiple parameters #148

glynnbird opened this issue Mar 15, 2019 · 1 comment

Comments

@glynnbird
Copy link
Contributor

The db.search function has an optional drilldown parameter which can be either

  1. an array e.g.
db.search('ddoc', 'search', {
  q: '*:*',
  drilldown: ['author','Dickens']
})

or

  1. an array of arrays e.g.
db.search('ddoc', 'search', {
  q: '*:*',
  drilldown: [['author','Dickens'],['publisher','Penguin']]
})

Expected Behavior

I should be able to supply an array on an array of arrays and have Nano produce the correct query string parameters.

Current Behavior

It is impossible to supply an array of arrays to drilldown. It incorrectly JSON.stringifies everything producing a server error.

Possible Solution

  • an array of strings should be JSON.stringified
  • an array of arrays should have its elements JSON.stringified
  • the outgoing Request object needs qsStringifyOptions = { arrayFormat: 'repeat' } to force the query string to become drilldown=["author","Dickens"]&drilldown=["publisher","Penguin"]

Steps to Reproduce (for bugs)

var Nano = require('nano')
var nano = Nano(url)
var db = nano.db.use('books')
db.search('search', 'search', {
  q: '*:*',
  counts: ['publisher'],
  drilldown: [ ['publisher', 'Penguin'], ['author', 'Charles Dickens'] ]
}).then(console.log)

Context

The drilldown parameter is designed to allow a user to winnow their search results by facets within the result set. They can select individual facets (publisher = penguin) and the result set will only contain matching values. Multiple drilldowns can be selected to refine the result set further. Nano only allows a top-level drilldown because it incorrectly handles arrays of arrays.

Your Environment

  • Node 10.14
  • Nano 8.0.0
glynnbird added a commit that referenced this issue Mar 18, 2019
* fix formatting of drilldown parameter for issue #148

* added tests

* added README for drilldown parameter
@bessbd
Copy link
Member

bessbd commented Jul 6, 2020

FYI, new releases of CouchDB allow for new ways of supplying drilldown: https://github.com/apache/couchdb-documentation/pull/561/files

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

No branches or pull requests

2 participants