Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-4781

start_key_docid returns unexpected (or unintuitive) results

    Details

      Description

      Below are the results from a query that returns multiple rows for a single key. The third document has id "0-8fbe114" but if I apply the start_key_docid filter I still get the same exact results with the list starting at doc id "0-14479a7." although the view should've returned a subset. I also tried start_key_docid in combination with start_key and end_key but neither of these returns a subset starting at the requested docid.

      QUERY WITH KEY = [2008,11,1]
      curl "http://10.1.2.104:8092/default/_design/dev_test_view-ed4bf91/_view/dev_test_view-ed4bf91?full_set=true&key=%5B2008%2C11%2C1%5D&connection_timeout=60000&debug=true" > query_with_key

      {"id":"0-2857e2f","key":[2008,11,1],"value":{"_id":"0-2857e2f","_rev":"1-000040a864a752c20000024c00000000","$flags":0,"$expiration":0,"name":"employee-0-...
      {"id":"0-2857e2f","key":[2008,11,1],"value":{"_id":"0-328e876","_rev":"1-000040a8b60c1357000001b800000000","$flags":0,"$expiration":0,"name":"employee-0-...
      {"id":"0-91f1a76","key":[2008,11,1],"value":{"_id":"0-91f1a76","_rev":"1-000040a6f0ddebd30000023500000000","$flags":0,"$expiration":0,"name":"employee-0-...
      {"id":"1-2857e2f","key":[2008,11,1],"value":{"_id":"1-2857e2f","_rev":"1-000040a86e8ccc2d0000024c00000000","$flags":0,"$expiration":0,"name":"employee-1-...
      {"id":"1-2857e2f","key":[2008,11,1],"value":{"_id":"1-328e876","_rev":"1-000040a8bffda165000001b800000000","$flags":0,"$expiration":0,"name":"employee-1-...
      {"id":"1-91f1a76","key":[2008,11,1],"value":{"_id":"1-91f1a76","_rev":"1-000040a7b360b9840000023500000000","$flags":0,"$expiration":0,"name":"employee-1-...
      {"id":"10-2857e2f","key":[2008,11,1],"value":{"_id":"10-2857e2f","_rev":"1-000040a9848f822f0000024f00000000","$flags":0,"$expiration":0,"name":"employee-10-...

      QUERY WITH KEY = [2008,11,1] and START_KEY_DOCID = "0-8fbe114"
      curl "http://10.1.2.104:8092/default/_design/dev_test_view-ed4bf91/_view/dev_test_view-ed4bf91?full_set=true&key=%5B2008%2C11%2C1%5D&start_key_docid=%220-8fbe114%22&connection_timeout=60000&limit=10&skip=0" > query_with_startkeydocid

      ....results are the same as previous query, although I expected them to start with the requested doc_id...

      Also noticed that "id" and "_id" are mismatch - not sure if that has something to do with the behavior of this filter.

      1. query_with_key
        208 kB
        Tommie McAfee
      2. query_with_key_and_startkeydocid
        208 kB
        Tommie McAfee
      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        tommie Tommie McAfee added a comment -

        Well, couple of things here, as I also thought this was unintuitive before understanding how this used to work in couchdb.

        Using startkey_docid requires 2 things:
        1 that the startkey filter is also used in the same query
        2 that the results returned from using startkey contain duplicate keys

        so if I have:

        { "key0" : "val0" "key1" : "val1" <_id = k1v1> "key1" : "val2" <_id = k1v2> "key1" : "val3" <_id = k1v3> "key2" : "val4" }

        I can do something like
        starkey = key1, startkey_doid = k1v2

        and my results would be

        { "key1" : "val2" <_id = k1v2> "key1" : "val3" <_id = k1v3> "key2" : "val4" }

        Could be in your case the only thing you need is startkey if all your map functions are emitting unique keys.

        Show
        tommie Tommie McAfee added a comment - Well, couple of things here, as I also thought this was unintuitive before understanding how this used to work in couchdb. Using startkey_docid requires 2 things: 1 that the startkey filter is also used in the same query 2 that the results returned from using startkey contain duplicate keys so if I have: { "key0" : "val0" "key1" : "val1" <_id = k1v1> "key1" : "val2" <_id = k1v2> "key1" : "val3" <_id = k1v3> "key2" : "val4" } I can do something like starkey = key1, startkey_doid = k1v2 and my results would be { "key1" : "val2" <_id = k1v2> "key1" : "val3" <_id = k1v3> "key2" : "val4" } Could be in your case the only thing you need is startkey if all your map functions are emitting unique keys.
        Hide
        francares francares added a comment -

        Same happens with string type keys.

        Show
        francares francares added a comment - Same happens with string type keys.
        Hide
        francares francares added a comment -
        Show
        francares francares added a comment - They are GUIDs. When I call to the view with following URLs: http://10.230.58.221:8092/test/_design/dev_appsByCategory/_view/appsByCategory?startkey_docid=%2200%22&connection_timeout=60000&limit=10&skip=0 or http://10.230.58.221:8092/test/_design/dev_appsByCategory/_view/appsByCategory?startkey_docid=00&connection_timeout=60000&limit=10&skip=0 It returns keys like 03057CA7-5F27-4364-87FD-892548D8CB43, so the filter is not performed in the view.
        Hide
        tommie Tommie McAfee added a comment -

        Yes, this was fixed in dp4. What do you're id's and keys look like?
        Depending on your docids, you should not have quote's around the startkey_docid, even if the id's are strings.

        Show
        tommie Tommie McAfee added a comment - Yes, this was fixed in dp4. What do you're id's and keys look like? Depending on your docids, you should not have quote's around the startkey_docid, even if the id's are strings.
        Hide
        francares francares added a comment -

        Does anyone know if this bug was fixed in DP4?
        I´m using Couchbase version: 2.0.0 community edition (build-724) and still happens. I´m using startkey_docid and startkey query params.

        Show
        francares francares added a comment - Does anyone know if this bug was fixed in DP4? I´m using Couchbase version: 2.0.0 community edition (build-724) and still happens. I´m using startkey_docid and startkey query params.

          People

          • Assignee:
            BigBlueHat Benjamin Young
            Reporter:
            tommie Tommie McAfee
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Due:
              Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes