couchdb search or filtering on key array

I have this in my view function:

emit([,doc.address.state,], doc);

When I query the search, I need to have all 3 elements of the array filled in, for example:

?key=["US","NY","New York"]

that will produce my records, but lets say for example, I just want to return everything in the US for example:


or in the US and State...


OR... lets say perhaps I want just all records from NY... (i know the below doesn't work)


I don't really get how to search if you want to leave one of the elements of the array empty?



key=["US"] will not work on an Array Key ["US","NY"], cause you're looking for a key that is EXACT ["US"]. Instead, you have to use


then those Keys are in the resultset:

["DE","Bavaria","Munich"]   <---- NO ! "DE" is out of Range of startkey
["US","FL","Miami"]         <---- YES, starts with "US"
["US","NY","New York"]      <---- YES, starts with "US"
["VE","XX","Vencuela City"] <---- NO ! "VE" is out of Range of endkey

Also Working:



["DE","Bavaria","Munich"]   <---- NO ! "DE" is out of Range of startkey
["US","FL","Miami"]         <---- YES, starts with "US","FL"
["US","NY","New York"]      <---- NO, "US","NY" is out of Range of endkey
["VE","XX","Vencuela City"] <---- NO ! "VE" is out of Range of endkey

Second: You cannot have blanks on left side.. so you have to write some more emits: ( you do not have to emit the second and third array-item, if you do not need to query it)

view "byStateCityCountry":

emit([doc.address.state,,], doc);

view "byCityStateCountry":

emit([,doc.address.state,], doc);

of just put a flag in the first place to determine the type of query, so you can do all in one View:

emit([1,,doc.address.state,], doc);
emit([2,doc.address.state,,], doc);
emit([3,,doc.address.state,], doc);



Need Your Help

ImportError: cannot import name 'ensure_dir_exists'

python jupyter-notebook

I update the Jupyter notebook from the old version to latest 5.3.1. However, when I try to launch the notebook from anaconda, it throws an import error:

Why isn't the navigationItem.titleView working?

iphone cocoa-touch

I'd like to put in an UIButton in the center of the navigation bar. Based on the document, it appears I need to set title view, and make sure the leftBarButtonItem is nil. But it is not work for me...