Open ThusStyles opened 9 years ago
Seems like you are not sending _id
for each documents from server.
I am sending them, if I do a console log of the data returned in the search source method then it shows documents with an _id field
I had this problem. Transporter was converting _id
to id
, so I fixed it by copying id
to _id
before returning the data in SearchSource.defineSource
.
I had exactly this problem whilst following along with the bulletproofmeteor Building a Real-World Search App – Meteor Package Search
tutorial. @lorensr 's reply above gave me the hint I needed but it didn't quite fit what I was seeing so here is my fix.
In your SearchSource.defineSource
there may well be a map
function similar to this:
_Before_
var data = result.hits.hits.map(function(doc) {
var source = _.clone(doc._source);
source._score = doc._score;
return source;
});
The problem is that this map does not include the _id
in the source
. So you need to update it to this:
_After_
var data = result.hits.hits.map(function(doc) {
var source = _.clone(doc._source);
source._score = doc._score;
source._id = doc._id; // <- add this line
return source;
});
Once you include the _id
into the source then the SearchSource
error goes away and all is well.
Thanks @biofractal, that fixed it for me!
Thanks @biofractal! I as well had the same issue, fixed me right up.
Getting strange random error, not sure exactly how to solve, search still works but stay loading forever and seems to cause cpu/memory leaks.
Exception in delivering result of invoking 'search.source': TypeError: Cannot read property '_str' of undefined at http://localhost:3000/packages/meteorhacks_search-source.js?b3122033999151d35259310e0ffa257e17669508:125:25 at Array.forEach (native) at Function..each..forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:11) at SearchSource._updateStore (http://localhost:3000/packages/meteorhacks_search-source.js?b3122033999151d35259310e0ffa257e17669508:123:5) at handleData (http://localhost:3000/packages/meteorhacks_search-source.js?b3122033999151d35259310e0ffa257e17669508:89:14) at Meteor.bindEnvironment as _callback at _.extend.maybeInvokeCallback (http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3860:12) at .extend.receiveResult (http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3880:10) at _.extend._livedata_result (http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:4970:9) at onMessage (http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3725:12)