0
# creating the view
var designDocContents =
@"{
    ""views"" : {
        ""all_docs"" : {
            ""map"" : ""function (doc, meta) {\n  emit(doc.name, [doc.version, doc.type, doc.date]);\n }""
        }
    }
}";
var result = _cluster.CreateDesignDocument(_bucketName, "dev_all_docs", designDocContents);

From my Visual Studio Immediate window while debugging:

# trying to get the created view and read values from it
couchbaseClient.GetView("dev_all_docs", "all_docs").GetEnumerator().MoveNext();
    false
couchbaseClient.GetView("dev_all_docs", "all_docs").GetEnumerator().MoveNext();
    true

As you can see the exact same code line (couchbaseClient.GetView...) returns false on the first call and true on the second call. I've tried adding sleep after creating the view, but that did not fix it, so it does not seem to be a timing issue.

I found a question that seemed somewhat related: Couchbase .Net client library GetView caching issue But the following change from the questions answer did not fix it either:

couchbaseClient.GetView("dev_all_docs", "all_docs").Stale(StaleMode.False);
Community
  • 1
  • 1
the_jov
  • 185
  • 1
  • 2
  • 8

1 Answers1

1

I figured it out. The problem was fixed by switching from using a development view to a production view. Having a closer look at the Couchbase view documentation was the key. http://docs.couchbase.com/couchbase-manual-2.2/#development-and-production-views

I changed the code to the following:

# creating the view
var designDocContents =
@"{
    ""views"" : {
        ""all_docs"" : {
            ""map"" : ""function (doc, meta) {\n  emit(doc.name, [doc.version, doc.type, doc.date]);\n }""
        }
    }
}";
var result = _cluster.CreateDesignDocument(_bucketName, "all_docs", designDocContents);

And in Visual Studio immediate window:

couchbaseClient.GetView("all_docs", "all_docs").GetEnumerator().MoveNext();
true

So in the code removing the "dev_" prefix from the view name did the trick.

the_jov
  • 185
  • 1
  • 2
  • 8