DesignDocument and support for options (auto-update options)


#1

I’d like to use the java client to perform upserts of my Design Documents programatically. It looks like this functionality exists but something seems to be missing. I define some of my Design Documents with auto update options. If I fetch the Design Document using the REST API, the resulting JSON looks something like this:

{
"views" : {
  "openByModified" : {
    "map" : "function (doc, meta) {\n  if(typeof doc.lastModified !== \"undefined\" && doc.open)  {\n emit(doc.lastModified, null);\n }\n }"
  }
},
"options" : {
  "updateInterval" : 60000,
  "updateMinChanges" : 1,
  "replicaUpdateMinChanges" : 1
  }
}

It’s that options section that I need support for in programmatically upserting a DesignDocument but I don’t see any coverage for this in the current (2.0.2) api. I can parse equivalent JSON into a Map and then use JsonObject.from to give me a JsonObject to plug into the DesignDocument constructor, but it seems like the options section is lost when I do this. Am I missing something or is this just not covered in the current API?


#2

You are exactly right, those options are currently not supported. Being honest, we didn’t have this on the radar when implementing Design Document support.

That said, we are currently working on 2.1.0 (for some spatial view goodness) and I need to touch those parts anyway. Do you want to raise an enhancement here with your requirements (http://www.couchbase.com/issues/browse/JCBC) or should I?

Also, we love contributions, so if you want to help adding it we can follow up in the ticket as well.


#3

You can only set the updateMinChanges and replicaUpdateMinChanges in the design document. The update interval is a global setting (/settings/viewUpdateDaemon). For the interval there’s already some bug open (MB-11594) in case you want to track it.

Update: the setting can be set through the REST API. Get the URI for the setUpdateMinChanges from /pools/default/buckets/<your-bucket-name>/ddocs


View auto update semantics
#4

I can create the enhancement. I reply again when I have done so with the link to the enhancement request. It seems like this change would be pretty small in scope (hopefully), so I’d be more than happy to help out with it. After I respond with the enhancement request, let me know what I need to do to contribute. My guess is to just fork the repo and take out a pull request when done; just want to confirm that.


#5

Interesting. I was unaware that setting that value (the update interval) at the Design Document level has no effect. Duly noted and good to know.


#6

Okay, @daschl, I have created the Improvement Request in JIRA:

http://www.couchbase.com/issues/browse/JCBC-652

Let me know how you want to proceed from here.


#7

Awesome, let’s tackle it in the ticket.


#8

@cbax007 I’m reviving this, since it’s now in review! http://review.couchbase.org/#/c/52828/ will be in 2.2 if it goes to plan.