Incorrect or missing data (user issue)

Incorrect or missing data (user issue)

Data missing in query response or it’s wrong (user issue)

For example, you defined a view with a _stats reduce function. You query your view, and keep getting empty results all the time, for example:

> curl -s 'http://localhost:8092/default/_design/dev_test3/_view/view1?full_set=true' {"rows":[ ] } 

You repeat this query over and over for several minutes or even hours, and you always get an empty result set.

Try to query the view with stale=false , and you get:

> curl -s 'http://localhost:8092/default/_design/dev_test3/_view/view1?full_set=true&stale=false' {"rows":[ ], "errors":[ {"from":"local","reason":"Builtin _stats function requires map values to be numbers"}, {"from":"","reason":"Builtin _stats function requires map values to be numbers"}, {"from":"","reason":"Builtin _stats function requires map values to be numbers"}, {"from":"","reason":"Builtin _stats function requires map values to be numbers"} ] } 

Then looking at the design document, you see it could never work, as values are not numbers:

{ "views": { "view1": { "map": "function(doc, meta) { emit(,; }", "reduce": "_stats" } } } 

One important question to answer is, why do you see the errors when querying with stale=false but do not see them when querying with stale=update_after (default) or stale=ok ? The answer is simple:

  1. stale=false means: trigger an index update/build, and wait until it that update/build finishes, then start streaming the view results. For this example, index build/update failed, so the client gets an error, describing why it failed, from all nodes where it failed.

  2. stale=update_after means start streaming the index contents immediately and after trigger an index update (if index is not up to date already), so query responses won’t see indexing errors as they do for the stale=false scenario. For this particular example, the error happened during the initial index build, so the index was empty when the view queries arrived in the system, whence the empty result set.

  3. stale=ok is very similar to (2), except it doesn’t trigger index updates.

Finally, index build/update errors, related to user Map/Reduce functions, can be found in a dedicated log file that exists per node and has a file name matching mapreduce_errors.# . For example, from node 1, the file *mapreduce_errors.1 contained:

[mapreduce_errors:error,2012-08-20T16:18:36.250,n_0@<0.2096.1>] Bucket `default`, main group `_design/dev_test3`, error executing reduce function for view `view1' reason: Builtin _stats function requires map values to be numbers