I am trying to learn MongoDB and for that implementing a chat server, using mongoose in the middleware.
I have a collection for messaging between two or more people lets name it chats, an entry for a chat is something like and I believe it is self-explanatory ;
{ "_id": "????", "roomName": "room2", "who": "VTAF", "message": "hello", "__v": 0, "time": "2015-09-16T20:05:55.863Z" }
SO I am currently storing all the chat history as flatten as possible since time and context of the message is important, should be searchable.
Is it reasonable to store the data as I did or would it cause performance issues?
Saving the message like this should have no problem in performance.. but if you want to be very fast in searching in text i would consider using ElasticSearch, but for this you would have to keep in sync 2 databases. Mongodb and elasticsearch.
While if you think it is a secondary feature ( searching ) just mongo will be ok
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.