如何在Marklogic中一次查询不同类型的文档图形? [英] How to query a graph of documents of different types at once in Marklogic?

查看:116
本文介绍了如何在Marklogic中一次查询不同类型的文档图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我第一次使用NoSql数据库支持图。这是一个处理数千名患者的巨大医疗应用程序。这是一个绿地项目,我们作为一个团队正在努力与我们的持久层。我们不知道应该如何表示关系,以及我们是否应该使用Triples来处理涉及大量数据的查询。 我们正在使用Java API



数据结构

<假设我们的Marklogic数据库中有三种类型的JSON文档:Patient,Event,File Evidence。



  • 应用程序中有数千名患者
  • 一名患者可能有多个与此相关的事件患者(承认,出院,转移,处方药物,补充说明,改变内部状态等)每个事件都可以附加多个文件作为证据
    $ b


假设有成千上万的患者,事件和文件。

问题 strong>



是否可以立即向事件和文件的患者查询?在我们的案例中推荐使用语义(可能的三元组:患者有事件,事件有文件)? 我们的方法



我们尝试使用三元组来提供我们文档之间的关系,将它们添加到一个图形中,使用组合查询先取IRI,然后再通过IRI调用fetch文档。我们尝试了自定进度的培训并探索 https://github.com/marklogic/marklogic-samplestack但没有运气。在过去曾经做过这样的事情,并希望分享他的经验的人的帮助会很好。

我的你的情况,请记住,您也可以将三元组存储在每个文档中(推断的主题是文档本身)。然后在你的例子中,你可以将cts:triple-range-query与标准cts:search结合起来。例如:
如果我有事件并且嵌入了一个三倍,例如[this event-> ownedByPatient - > [iri / for / patiens#12345]

然后我可以查询:
搜索由片段过滤的事件cts:triple-range-query指出事件由患者拥有12345



这种方法是语义和MarkLogic搜索的结合 - 使用三元组链接适当的



至于不同类型的文件,triples不关心他们指的是什么 - 一个人,事件等的IRI。它只是关于你如何建模你的数据本身和用来描述关系的本体论。所以,你也可以将它作为托管三元组(不嵌入),并将其视为指向你的内容的图形数据库(就像你描述的方法一样)。

一次你可以继续前进,也可以决定强制使用RDF规则来限制关系类型。


Background

I'm using NoSql database supporting graphs for the first time. It is a huge medical application handling thousands of patients. It is a greenfield project and we as a team are struggling with our persistence layer. We don't know how relationships should be represented and if we should use Triples to handle queries involving huge amount of data. We are using Java API.

Data structure

Imagine that there are 3 types of JSON documents in our Marklogic database: Patient, Event, File Evidence.

  • There are thousands of patients in the application
  • One patient can have multiple events associated with this patient (admitted, discharged, transferred, prescribed medications, added note, changed internal status etc.)
  • each event can have multiple files attached to it as an evidence

Assume there are hundreds of thousands of patients, events and files.

Question

Is it possible to query patients with events and files at once? Is using semantics (possible triples: 'patient has event', 'event has file') recommended in our case?

Our approach

We try to use triples to provide relationships between our documents, add them to one graph, use combination query to fetch IRI first and then in the second call fetch documents by IRI. We tried self-paced trainings and exploring https://github.com/marklogic/marklogic-samplestack but with no luck. Help of someone who has done that in the past and would like to share his experience would be great.

解决方案

I your situation, keep in mind that you can also store the triples in each of the documents themselves (with the inferred subject being the document itself). Then in your example, you could be combining cts:triple-range-query with standard cts:search.

Example: If I had events and embedded a triple such as [this event-> ownedByPatient -> [iri/for/patiens#12345]

Then I could query: search for events filtered by fragments where the cts:triple-range-query states that the events are owned by patient 12345

This approach is a combination of semantics and MarkLogic search - using triples to link the appropriate types.

As for different types of documents, triples do not care what they are pointing at - an IRI of a person, event, etc. Its just about how you model you data itself and the ontology used to describe the relationships. So, you can also approach this as managed triples (not embedded) and treat it all as a graph database pointing at your content (like the approach you are describing)

Once you get further along, you may also decide to force restrictions on the types of relationships using RDF rules.

这篇关于如何在Marklogic中一次查询不同类型的文档图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆