meteorhacks / search-source

Reactive Data Source for Search
MIT License
146 stars 33 forks source link

Transform highlighting doesn't work on _id #55

Open dkmooers opened 8 years ago

dkmooers commented 8 years ago

If I use this transform function for highlighting search results:

transform: function(matchText, regExp) {
    console.log(matchText, regExp);
    return matchText.replace(regExp, "<b>$&</b>");
},

And I use '_id' as one of the search fields, I get the following error when I search:

Exception in template helper: Error: transformed document can't have different _id
    at wrapped [as _transform] (http://localhost:3000/packages/minimongo.js?hash=9b1463853801ce7302ecca3eac339c514a0341db:1174:15)
    at http://localhost:3000/packages/minimongo.js?hash=9b1463853801ce7302ecca3eac339c514a0341db:200:18
    at Array.forEach (native)
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=8de51f9d86e95ae2ffee15a8db324a1decccba3e:139:11)
    at LocalCollection.Cursor.forEach (http://localhost:3000/packages/minimongo.js?hash=9b1463853801ce7302ecca3eac339c514a0341db:195:5)
    at LocalCollection.Cursor.fetch (http://localhost:3000/packages/minimongo.js?hash=9b1463853801ce7302ecca3eac339c514a0341db:238:8)
    at SearchSource.getData (http://localhost:3000/packages/meteorhacks_search-source.js?hash=0b4c91bf433d5d896a2beba7db436da54fc8f842:184:17)
    at Object.invoices (http://localhost:3000/app/app.js?hash=476b27c1277f65d46aa8bc18f3c3d4243f7322ec:1049:45)
    at http://localhost:3000/packages/blaze.js?hash=38069f4f7cfbd8898160bc97d37dd847cd5985fe:2984:16
    at http://localhost:3000/packages/blaze.js?hash=38069f4f7cfbd8898160bc97d37dd847cd5985fe:1643:16

Is there any way to get _id searching / transforming to work?

gabrielps commented 7 years ago

I have the same issue. Anyone?