여기에서 내가 뭘 잘못하고 있는지 알 수 없습니다. 나는 코드를 (문서의 모든 속성에 직접 액세스 할 수 있습니다 감소/pymongo을 사용하지 않고 다음과 같은지도가있어 -하여 예에는 내장 부품 관련 여기 :pymongo 사용자 어설 션 : 13606 : 'out'은 문자열 또는 객체 여야합니다.
() 파일 getTableMap.js에 :
function() {
var tablePoints1 = 0;
var tablePoints2 = 0;
if (this.pointsTeam1 == this.pointsTeam2) {
tablePoints1 = 1;
tablePoints2 = 1;
}
else {
if (this.pointsTeam1 > this.pointsTeam2) {
tablePoints1 = 3;
}
else {
tablePoints2 = 3;
}
}
emit(this.idTeam1, [tablePoints1, this.pointsTeam1, this.pointsTeam2]);
emit(this.idTeam2, [tablePoints2, this.pointsTeam2, this.pointsTeam1]);
}
map_reduce를 호출하는 파이썬 코드는 다음과 같습니다 http://api.mongodb.org/python/current/examples/map_reduce.htmlMap Reduce example from pymongo 2.0.1 documentation
: 파이썬 코드def getTableOnMatchday(self):
m = Code(open('getTableMap.js','r').read())
r = Code("""function(k,values) {
var foo = 'foo';
return(foo);
}""")
result = bl_1.map_reduce(m, r, "myresult")
for doc in result.find():
print doc
내가 바로 문서에서 간단한 예를 적응 내가 코드를 실행했을 때 얻을
파이썬 역 추적은 다음과 같습니다
>>> api.getTableOnMatchday()
Traceback (most recent call last):
pymongo.errors.OperationFailure: command SON([('mapreduce', u'bl1_2011'),
...
...
...
) failed: db assertion failure
그건 정확히 너무 많이 말하지 않았다 내가 로그에이 자세한에의 mongod 로깅을 설정하고 발견
Thu Sep 15 21:04:02 [conn7] User Assertion: 13606:'out' has to be a string
or an object
실제로 map_reduce 호출을 생성하는 Python 코드를 보면 세 번째 매개 변수 ('out'은 pymongo 2.0.1 문서에 따라)는 'myresult'입니다. 이것은 확실히 문자열입니다.
여기에 대해 불평하는 pymongo 란 무엇입니까? Javascript는 문법적으로 정확합니다 (제 생각 엔). 줄이기는 현재 아무 것도하지 않지만이 명령으로 서버 측 컴파일을 막지 않아야합니다. 아니면 어쩌면 가능합니까?