2014-12-16 2 views
0

나는 전체 텍스트 검색유성과 함께 작동하도록 적응하려고합니다. mongodb URL을 2.6.1을 실행하는 하나에 내 보냈습니다. 전체 텍스트 검색을 호환 가능하게하려면이 오류가 발생합니다. server/search.js:2:15: Unexpected token .server/search.js:42:7: Unexpected token). 내가 뭘 놓치고 있니?유성으로 뛰게하려면 무엇을 잘못하고 있습니까?

server.js

Meteor.methods({ 
    Meteor.ensureIndex("Posts", { 
     smaintext: "text" 
    }, function(err, indexname) { 
     assert.equal(null, err); 
    }); 
) 
}; 


Meteor.methods({ 
    feedupdate: function(req) { 
     Posts.find({ 
     "$text": { 
      "$search": req 
     } 
     }, { 
     smaintext: 1, 
     submitted: 1, 
     _id: 1, 
     Posts: { 
      $meta: "Posts" 
     } 
     }, { 
     sort: { 
      textScore: { 
      $meta: "posts" 
      } 
     } 
     }).toArray(function(err, items) { 
     for (e=0;e<101;e++) { 
     Meteor.users.update({ 
      "_id": this.userId 
     }, { 
      "$addToSet": { 
      "profile.search": item[e]._id 
      } 
     }); 
    } 
     }) 
    } 
) 
}; 

답변

1

이 방법의 문제 정의

Meteor.methods({ 
Meteor.ensureIndex("Posts", { 
    smaintext: "text" 
}, function(err, indexname) { 
    assert.equal(null, err); 
}); 

) }이고;

당신은 메소드 이름 (http://docs.meteor.com/#/basic/Meteor-methods) 를 지정해야합니다 그래서 두 번째 방법이
Meteor.methods({ myMethodName : function() { Meteor.ensureIndex("Posts", { smaintext: "text" }, function(err, indexname) { assert.equal(null, err); }); } });

같은 뭔가 semicron 및 parenthise 문제가 될 것입니다. 올바른 버전은

Meteor.methods({ 
feedupdate: function(req) { 
    Posts.find({ 
    "$text": { 
     "$search": req 
    } 
    }, { 
    smaintext: 1, 
    submitted: 1, 
    _id: 1, 
    Posts: { 
     $meta: "Posts" 
    } 
    }, { 
    sort: { 
     textScore: { 
     $meta: "posts" 
     } 
    } 
    }).toArray(function(err, items) { 
    for (e=0;e<101;e++) { 
    Meteor.users.update({ 
     "_id": this.userId 
    }, { 
     "$addToSet": { 
     "profile.search": item[e]._id 
     } 
    }); 
} 
    }); 
} 

}입니다.

관련 문제