简体   繁体   English

MarkLogic:在某些情况下将文档从一个目录移动到另一个目录

[英]MarkLogic: Move document from one directory to another on some condition

I'm new to MarkLogic and trying to implement following scenario with its Java API: 我是MarkLogic的新手,并尝试使用其Java API实现以下方案:

  1. For each user I'll have two directories, something like: 对于每个用户,我将有两个目录,例如:

    1.1. 1.1。 user1/xmls/recent/ user1 / xmls / recent /

    1.2. 1.2。 user1/xmls/archived/ user1 / xmls / archived /

  2. When user is doing something with his xml - it's put to the "recent" directory; 当用户使用他的xml做某事时-它被放置在“最近”目录中;
  3. When user is doing something with his next xml and "recent" directory is full (eg has some amount of documents, let's say 20) - the oldest document is moved to the "archived" directory; 当用户使用他的下一个xml做某事并且“最近”目录已满(例如,有一些文档,比如20)时,最旧的文档将移至“已归档”目录;
  4. User can request all documents from the "recent" directory and should get no more than 20 records; 用户可以从“最近”目录中请求所有文档,并且应获得不超过20条记录;
  5. User can remove something from the "recent" directory manually; 用户可以手动从“最近”目录中删除某些内容; In this case, if it had 20 documents, after deleting one it must have 19; 在这种情况下,如果有20个文档,则在删除一个文档后必须有19个文档;
  6. User can do something with his xmls simultaneously and "recent" directory should never become bigger than 20 entries. 用户可以同时使用自己的xml进行操作,“最近”目录的大小永远不能超过20个条目。

Questions are: 问题是:

  1. In order to properly handle simultaneous adding of xmls to the "recent" directory, should I block whole "recent" directory when adding new entry (to actually add it, check if there are more than 20 records after adding, select the oldest 21st one and move it to the "archived" directory and do all these steps atomically)? 为了正确地将xmls同时添加到“最近”目录中,在添加新条目时是否应该阻止整个“最近”目录(要实际添加,请检查添加后是否有20条以上的记录,选择最早的第21条记录并将其移至“已归档”目录,然后自动执行所有这些步骤)? How can I do it? 我该怎么做?
  2. Any suggestions on how to implement this via Java API? 关于如何通过Java API实施此操作的任何建议?
  3. Is it possible to change document's URI (eg replace "recent" with "archived" in my case)? 是否可以更改文档的URI(例如,在我的情况下,将“ recent”替换为“ archived”)?
  4. Should I consider using MarkLogic's collections here? 我应该在这里考虑使用MarkLogic的集合吗?

I'm open to any suggestions and comments (as I said I'm new to MarkLogic and maybe my thoughts on how to handle described scenario are completely wrong). 我乐于接受任何建议和评论(正如我所说的,我是MarkLogic的新手,也许我对如何处理所描述场景的想法是完全错误的)。

  1. You can achieve atomicity of a sequence of transactions using Multi-Statement Transactions (MST) 您可以使用多语句事务(MST)实现事务序列的原子性
  2. It is possible to MST from the Java API: http://docs.marklogic.com/guide/java/transactions#id_79848 可以通过Java API进行MST: http : //docs.marklogic.com/guide/java/transactions#id_79848
  3. It's not possible to change a URI. 无法更改URI。 However, it is possible to use an MST to delete the old document and reinsert a new one using the new URI in one an atomic step. 但是,可以使用MST在一个原子步骤中删除旧文档并使用新URI重新插入新文档。 This would have the same effect. 这将具有相同的效果。
  4. Possibly, and judging from your use case, unless you must have the recent/archived information as part of the URI, it may be simpler to store this information in collections. 从用例来看,除非您必须将最新/存档信息作为URI的一部分,否则将这些信息存储在集合中可能会更简单。 However, you should read the documentation and evaluate for yourself: http://docs.marklogic.com/guide/search-dev/collections#chapter 但是,您应该阅读文档并自己进行评估: http : //docs.marklogic.com/guide/search-dev/collections#chapter

Personally I would skip all the hassle with separate directories as well as collections. 就个人而言,我会跳过所有带有单独目录和集合的麻烦。 You would endlessly have to move files around, or changes their properties. 您将无休止地移动文件或更改文件的属性。 It would be much easier to not calculate anything up front, and simply use lastModified property, or something alike, to determine most recent items at run-time. 不预先计算任何东西,而仅使用lastModified属性或类似方法来确定运行时的最新项目会容易得多。

HTH! HTH!

暂无
暂无

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

相关问题 如何根据Spring Integration中的某些验证将文件从一个目录移动到另一个目录? - how to move files from one directory to another depending on some validations in spring integration? 将文档从一个集合移到另一个集合将覆盖该文档 - Move document from one collection to another is overwriting the document Java:将文件从一个目录复制/移动到另一个目录的安全方法 - Java: Safe way to copy/move files from one directory to another 如何将文件从一个目录移动到另一个目录 - How can move file from one directory to another 如何将所有文件从一个目录移动并覆盖到另一个目录? - How to move and overwrite all files from one directory to another? 如何从有条件的活动转移到另一个活动? - How to move from activity to another with condition? Hadoop:如何将HDFS文件从一个目录移动到另一目录? - Hadoop: How to move HDFS files in one directory to another directory? 如何使用java将文件一个目录移动到另一个目录 - How to move file one directory to another directory using in java 如何使用Spring Integration File Support创建一种将文件从一个目录移动到另一个目录的方法? - How to create a method to move file from one directory to another using Spring Integration File Support? 如何从特定条件下的目录中获取文件,一个文件必须接着另一个文件 - How to get files from a directory on specific condition one file must come after another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM