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

API for defining views in more declarative way

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0
    • Fix Version/s: feature-backlog
    • Component/s: view-engine
    • Security Level: Public
    • Labels:
      None

      Description

      It would be nice to have some built-ins for defining mappers based on document attributes without writing actual Javascript code, like we can do it with reducers (_sum, _stats, _count)

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        vmx Volker Mische added a comment -

        I've assigned it to me, since I'd like to know what happens to it (and it doesn't matter who if the view-engine teams owns).

        Anyone feel free to assign it to yourself if you want to come up with a nice syntax.

        Show
        vmx Volker Mische added a comment - I've assigned it to me, since I'd like to know what happens to it (and it doesn't matter who if the view-engine teams owns). Anyone feel free to assign it to yourself if you want to come up with a nice syntax.
        Hide
        jasdeep jasdeep added a comment -

        The idea is straightforward, we are making collection indexes on a single field:

        if (match_json_key_a, value_a) index (json_key_b)

        which translates to:

        function(doc,meta) {
        if (doc.json_key_a == value_a)

        { emit(json_key_b); }

        }

        The method syntax can be something like:

        create_index(index_name, collection_json_key, collection_json_value, index_json_key, [optional_json_key_value_output])

        Example #1:

        create_index("all_users_by_email", "doctype", "user", "email")

        Translates to:

        View Name: all_users_by_email

        function(doc,meta) {
        if (doc.doctype == "user")

        { emit(doc.email); }

        }

        Example #2 (with output value):

        create_index("all_users_by_email", "doctype", "user", "email", "uid")

        Translates to:

        View Name: all_users_by_email

        function(doc,meta) {
        if (doc.doctype == "user")

        { emit(doc.email, doc.uid); }

        }

        Show
        jasdeep jasdeep added a comment - The idea is straightforward, we are making collection indexes on a single field: if (match_json_key_a, value_a) index (json_key_b) which translates to: function(doc,meta) { if (doc.json_key_a == value_a) { emit(json_key_b); } } The method syntax can be something like: create_index(index_name, collection_json_key, collection_json_value, index_json_key, [optional_json_key_value_output] ) Example #1: create_index("all_users_by_email", "doctype", "user", "email") Translates to: View Name: all_users_by_email function(doc,meta) { if (doc.doctype == "user") { emit(doc.email); } } Example #2 (with output value): create_index("all_users_by_email", "doctype", "user", "email", "uid") Translates to: View Name: all_users_by_email function(doc,meta) { if (doc.doctype == "user") { emit(doc.email, doc.uid); } }
        Hide
        vmx Volker Mische added a comment -

        Perhaps it could be more JSON like (people using Couchbase should know JSON).

        Example #1:

        {
        "name": all_users_by_email",
        "filter":

        { "key": "doctype", "value": "user" }

        ,
        "emit":

        { "key": "email" }

        }

        Example #2

        {
        "name": all_users_by_email",
        "filter":

        { "key": "doctype", "value": "user" }

        ,
        "emit":

        { "key": "email", "value": "uid" }

        }

        Show
        vmx Volker Mische added a comment - Perhaps it could be more JSON like (people using Couchbase should know JSON). Example #1: { "name": all_users_by_email", "filter": { "key": "doctype", "value": "user" } , "emit": { "key": "email" } } Example #2 { "name": all_users_by_email", "filter": { "key": "doctype", "value": "user" } , "emit": { "key": "email", "value": "uid" } }
        Hide
        jasdeep jasdeep added a comment -

        Sure, i just picked that style as a way to express the idea

        Show
        jasdeep jasdeep added a comment - Sure, i just picked that style as a way to express the idea
        Hide
        jasdeep jasdeep added a comment -

        One question I had was how to optimize these so that we can have more of them than other VIews, how can we reduce the overhead so that many more of these can live in a design document. I thought the JSON pointer might be one way since it's really not V8 that is a bottleneck. At least we reduce the needs to convert to JSON objects for each document, although the cost of that is shared amongst all Map functions (right?), or is that per Design Document/Indexer?

        Show
        jasdeep jasdeep added a comment - One question I had was how to optimize these so that we can have more of them than other VIews, how can we reduce the overhead so that many more of these can live in a design document. I thought the JSON pointer might be one way since it's really not V8 that is a bottleneck. At least we reduce the needs to convert to JSON objects for each document, although the cost of that is shared amongst all Map functions (right?), or is that per Design Document/Indexer?
        Hide
        vmx Volker Mische added a comment -

        This is not about performance, this is about convenience. The map functions currently aren't the bottle neck.

        Show
        vmx Volker Mische added a comment - This is not about performance, this is about convenience. The map functions currently aren't the bottle neck.
        Hide
        dipti Dipti Borkar added a comment -

        Marty, is this something you are looking at ?

        Show
        dipti Dipti Borkar added a comment - Marty, is this something you are looking at ?
        Hide
        siri Sriram Melkote added a comment -

        Retarget as 3.0 is feature complete

        Show
        siri Sriram Melkote added a comment - Retarget as 3.0 is feature complete
        Hide
        vmx Volker Mische added a comment -

        This issue got stale hence it doesn't seem there's real demand for it. Additionally we have N1QL now. Hence closing this issue.

        Show
        vmx Volker Mische added a comment - This issue got stale hence it doesn't seem there's real demand for it. Additionally we have N1QL now. Hence closing this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            avsej Sergey Avseyev
          • Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes