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:
shell> curl -s 'http://localhost:9500/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:
shell> curl -s 'http://localhost:9500/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":"http://192.168.1.80:9502/_view_merge/?stale=false","reason":"Builtin _stats function requires map values to be numbers"}, {"from":"http://192.168.1.80:9501/_view_merge/?stale=false","reason":"Builtin _stats function requires map values to be numbers"}, {"from":"http://192.168.1.80:9503/_view_merge/?stale=false","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(meta.id, meta.id); }", "reduce": "_stats" } } }
One important question to make 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:
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.
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.
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@192.168.1.80:<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