rwynn / monstache

a go daemon that syncs MongoDB to Elasticsearch in realtime. you know, for search.
https://rwynn.github.io/monstache-site/
MIT License
1.28k stars 181 forks source link

[Bug] monstache converting mongodb _id (which is a string) to mongodb ObjectId #409

Open Bhanu220290 opened 4 years ago

Bhanu220290 commented 4 years ago

For ex- Suppose I have 2 database ( db1 & db 2) and in db1 i have one collection called col1 inside this collection we have following fields db1.col1 {_id:'string', //which looks like mongodb id because we migrated it from another mongodb server and pushed into our db name :'string', category:{ id:'string' //this id is associated with another db's collection ie db2.col2 (which is also looks like mongodb id) } } //db2.col2 {_id:'string',//which looks like mongodb id because we migrated it from another mongodb server and pushed into our db name:'string', age:'string' }

I wrote one transformation script that will fetch the data from another db's collection ie(db2.col2) and extend the response with the respective document but the script is not able to get the data from another db ie db2 because when we try to fetch the data, the monstache converts it's category.id to mongodb objectid, due to this we got empty response as a result but if we update our mongodb collection document id to objectId then it's working but that solution is not feasible for me to update my 10K records. so please provide me a solution of this problem.

rwynn commented 4 years ago

@Bhanu220290 I think this is due to a choice that was made in the javascript integration. Until a longer term fix is available I think you can fix it by making a small change to monstache. Here you would change the line to remove the call to restoreIds:

fc.query = deepExportValue(q)

Alternatively, if you use a golang plugin instead of javascript you can avoid this problem.

Bhanu220290 commented 4 years ago

@rwynn Thank you for your prompt reply and for your solution.