0

次のスクリプトを使用して、MongoDB の文字列のデータを分割してカウントしました。値の処理中にエラーが発生しnullます。親切に私を助けてください。

map = function() {
    var array = this.characters.split(',');
    emit(this.characters, array.length);
}

reduce = function(key, values) {
    return values[0];
}

result = db.runCommand({
    "mapreduce" : "book", 
    "map" : map,
    "reduce" : reduce,
    "out" : "comma_result1"
});

このエラーが発生しています:

"errmsg" : "exception: map invoke failed: JS Error: TypeError: this.characters has no properties nofile_b:1"
4

1 に答える 1

1

this.charactersがnullの場合、this.characters.split()を呼び出すと例外が発生します。

于 2012-11-13T00:50:05.367 に答える