Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7648781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:48:11+00:00 2026-05-31T10:48:11+00:00

I have this in my view function: emit([doc.address.country,doc.address.state, doc.address.city], doc); When I query the

  • 0

I have this in my view function:

emit([doc.address.country,doc.address.state, doc.address.city], 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:

?key=["US"]   

or in the US and State…

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

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

?key=["","NY"]

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:48:12+00:00Added an answer on May 31, 2026 at 10:48 am

    First:

    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

    startkey=["US"]&endkey=["US",{}] 
    

    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:

    startkey=["US","FL"]&endkey=["US","FL",{}] 
    

    result:

    ["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.address.city,address.country], doc);
    

    view “byCityStateCountry”:

    emit([address.city,doc.address.state, doc.address.country], 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,address.country,doc.address.state, doc.address.city], doc);
    emit([2,doc.address.state, doc.address.city,address.country], doc);
    emit([3,address.city,doc.address.state, doc.address.country], doc);
    

    Usage:

    ?startkey=[1,"US"]&endkey=[1,"US",{}]
    ?startkey=[2,"FL"]&endkey=[2,"FL",{}]
    ?startkey=[3,"Miami"]&endkey=[3,"Miami",{}]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this view function: def search(request): if request.method == 'GET': form = SearchForm(request.GET)
I have code like this in my view model: function ChatListViewModel(chats) { var self
In the main view i have this function public function lang($file, $language){ require 'languages/'.$language.'/'.
I have this Javascript: <script language=javascript type=text/javascript> $().ready(function() { $('#ex2').jqm({ajax: 'view.php?id=<?=$objResult[id];?>', trigger: 'a.ex2trigger'}); });
I have grid something like this: Ext.define('Exp.view.dashboard.Tv', { extend: 'Ext.grid.Panel', initComponent: function() { this.columns
I have this function: function view ( $id ) { $this->layout = 'page'; $this->User->id
I have this code in my view function Validate() { if (document.getElementById('MandateName').value == )
I have this code for view: App.TodoView = Em.View.extend({ labelView: Em.TextField.extend({ }), createNew:function ()
I have this view @model IEnumerable<ViewModelRound2> ... <snip> ... @{ using (Html.BeginForm(new { round1Ring3Bids
I have this view (DetailsContainer, first class in code section of this question) with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.