Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-244

Striped queries

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • Database Core
    • None
    • Committers Level (Medium to Hard)

    Description

      I have implemented striped queries, where you can specify multiple startkey/endkey ranges in a single request. As a nice side effect this allows faceted search (for discrete keys). Heres an example:

      Say I have the following map function:

      function() {
      emit([doc.rooms, doc.price], doc);
      }

      where doc.rooms and doc.price are both integers. Now lets say i want to find every document with a number of rooms between 2 and 4 and a price between 100 and 1000. I can then do the following query:

      db.view("my_view",{},{stripes: [

      {startkey: [2, 100], endkey: [2, 1000]}

      ,

      {startkey: [3, 100], endkey: [3, 1000]}

      ,

      {startkey: [4, 100], endkey: [4, 1000]}

      ]});

      If the view included a reduce function that would work too.

      As you can probably see this patch introduced a change to the JS API (but not the HTTP). The keys parameter is now a hash which can either take a keys param or a stripes. The keys param works as before. The stripes param takes an array of hashes each having a startkey, endkey key.

      The state of the patch is still somewhat raw, with no error checking on the stripes part of the API. Furthermore it might be useful to extend the limit, skip and descending options to the stripes.

      The patch is against the current trunk version (rev 742925) and all tests pass.

      Attachments

        1. striped_queries.diff
          31 kB
          Frederik Fix

        Activity

          People

            Unassigned Unassigned
            derfred Frederik Fix
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: