Home > OS >  Priority of documents in elasticsearch
Priority of documents in elasticsearch

Time:09-13

I have rails app witch collect mobile data and use elastic search as search engine in my app, As result that my app is very simple I use elastic as my db, every things goes fine till I found something amazing

In my case each user have two kind of document with different attributes, First one is profile that it's about user profile only and Second one is events that is user actions in mobile app. I have to say، user could update his/her profile and each user just have to one document in my system, that is about profile details. each time user update his profile I delete previous document and create new document for him but assume he send profile twice at same time unconsciously for example push register bottom twice at this point i get two document that are completely same so elastic save both but as i say i need to delete old one and create new one, I know I could handle this problem in mobile layer but I'm looking for some way witch make me sure at this situation document have their priorities.

CodePudding user response:

I really hope I got your point correctly, consider the following points

  • prevent users from submitting twice in your front end.
  • update the document instead of deleting the previous one then creates a new document so that you don't have to worry about document priorities because of a single file.

CodePudding user response:

Basically you need a versioning of your documents and using that you can control whether you need to create a new document or update existing document. this official Elasticsearch version control blog should help you design and implement this use-case.

  • Related