简体   繁体   English

elasticsearch中文件的优先级

[英]Priority of documents in elasticsearch

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我有 Rails 应用程序女巫收集移动数据并在我的应用程序中使用弹性搜索作为搜索引擎,结果我的应用程序非常简单我使用弹性作为我的数据库,一切都很好,直到我发现了一些惊人的东西

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.每次用户更新他的个人资料时,我都会删除以前的文档并为他创建新文档,但假设他无意识地同时发送了两次个人资料,例如,此时将注册底部推两次,我得到两个完全相同的文档,因此可以同时保存两个文档,但是因为我说我需要删除旧的并创建新的,我知道我可以在移动层处理这个问题,但我正在寻找某种方式来确保我在这种情况下文档有他们的优先级。

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.更新文档而不是删除以前的文档,然后创建一个新文档,这样您就不必因为单个文件而担心文档优先级。

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.这个官方的 Elasticsearch 版本控制博客应该可以帮助您设计和实现这个用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM