Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on duplication #5

Closed
Crispy1975 opened this issue Nov 11, 2016 · 2 comments
Closed

Question on duplication #5

Crispy1975 opened this issue Nov 11, 2016 · 2 comments

Comments

@Crispy1975
Copy link
Contributor

Just started testing with monstache and so far very impressed. I have a quick question regarding duplicates; specifically how are MongoDB _id properties mapped to ElasticSearch, and how when a document in MongoDB is updated is the correct ElasticSearch document updated?

@rwynn
Copy link
Owner

rwynn commented Nov 11, 2016

The default mapping is as follows:

mongodb database -> elasticsearch index
mongodb collection -> elasticsearch type
mongodb document _id -> elasticsearch document id

Any operation on a mongo document (insert, update, delete) will be recorded in the oplog with it's database, collection, and _id and that individual operation will eventually be folded into a bulk index command to ES (with other operations) where the index, type and _id are generated according to the mapping above. That is how it manages to index, update, or delete the correct ES document.

However, I think you may be correct about the potential for collisions since mongo _ids are unique at the collection level (not guaranteed across the database) while ES ids must be unique at the index level.

According to link, duplicate _ids across the database are unlikely with autogenerated _ids.

Regardless, I should change the default mapping such that

elasticsearch index <- mongodb database . mongodb collection

Thanks for giving monstache a try and reporting this issue.

@rwynn rwynn closed this as completed in 75ff512 Nov 13, 2016
@Crispy1975
Copy link
Contributor Author

Awesome, thanks. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants