Jackrabbit XPath 问题

发布于 2024-11-18 17:53:42 字数 1496 浏览 4 评论 0原文

我对 Jackrabbit 比较陌生。在我们的应用程序中,我们从未打开repository.xml(以及workspace.xml)文件中的SearchIndex部分,因为我们总是使用JCR UUID引用直接转到给定文档。我们使用 Jackrabbit v2.2.1Oracle 作为存储库。现在我们的需求正在扩大,因为我们希望使用文档元数据功能来存储有关文档的上下文信息,以便我们可以使用元数据来检索一组选定的文档。

第一步,我在workspace.xml 文件中添加了默认的SearchIndex 部分并重新启动了JCR。

我在日志文件中看到了一堆这样的行 - 然后我看到它在工作区区域下创建了索引文件夹。

2011-07-05 15:04:01.724 信息 [WebContainer : 0] MultiIndex.java:1204 索引... /vfs:metaData/21ee130e-978e-415f-bfd1-7aa03d91​​608c/vfs:attributes (3500)< /strong>

我有这样的文件夹结构。当我在 JCR 中创建文档时,我将元数据信息指定为文档的一部分,该文档由带有 docType、uploadedBy、contextValue 等标签的复杂 XSD 类型指定。

/ (root)
  /MyApp (sub-folder) 
      /documents/ (sub-folder) 
         /document-1.pdf (file) 
         /document-2.pdf (file) 
     /accounts/ (sub-folder) 
         /account.txt (file) 
        etc... 

以下 XPath 表达式有效。

//jcr:root/vfs:metaData//*[vfs:attributes/vfs:docType='TAX_DOCS']

如果我给出了错误的值,例如不是 'TAX_DOCS'、'TAX',它没有按预期返回任何文档,这很好。这证明元数据已按预期正确存储,并且在过滤过程中正确使用。

此查询的问题是它从根文件夹开始搜索,但我只想从 /MyApp/documents 子文件夹搜索。所以我尝试了这个:

//jcr:root/MyApp/documents//vfs:metaData//*[vfs:attributes/vfs:docType='TAX_DOCS']

它什么也不返回。然后我也尝试了这个但没有成功。

//jcr:root/MyApp/documents//*[vfs:metaData/vfs:attributes/vfs:docType='TAX_DOCS']

那么我做错了什么? workspace.xml 配置中是否有我们需要设置或丢失的内容?

任何帮助表示赞赏。

谢谢,杰克

I'm relatively new to Jackrabbit. In our application we never turned on SearchIndex section within repository.xml (so as workspace.xml) files because we always go directly to a given document using the JCR UUID reference. We are using Jackrabbit v2.2.1 and Oracle as the repository. Now our requirements are getting expanded as we would like to use the document metadata feature to store contextual info about a document so that we can use the metadata to retrieve a selected set of documents.

As the first step, I added the default SearchIndex section in workspace.xml file and restarted the JCR.

I saw a bunch of lines like this in my log file - then I saw it created the index folder under workspace area.

2011-07-05 15:04:01.724 INFO [WebContainer : 0] MultiIndex.java:1204 indexing... /vfs:metaData/21ee130e-978e-415f-bfd1-7aa03d91608c/vfs:attributes (3500)

I have the folder structure like this. When I create a document in JCR, I specify the metadata info as part of the document which is by a complex XSD type with tags like docType, uploadedBy, contextValue, etc.

/ (root)
  /MyApp (sub-folder) 
      /documents/ (sub-folder) 
         /document-1.pdf (file) 
         /document-2.pdf (file) 
     /accounts/ (sub-folder) 
         /account.txt (file) 
        etc... 

The following XPath expression works.

//jcr:root/vfs:metaData//*[vfs:attributes/vfs:docType='TAX_DOCS']

If I give wrong value, for example instead of 'TAX_DOCS', 'TAX', it returns no documents as expected which is great. This proves that the metadata is correctly stored as expected and it is used in the filter process correctly.

The problem with this query is that it starts searching from the root folder but I want to search from /MyApp/documents sub-folder only. So I tried this:

//jcr:root/MyApp/documents//vfs:metaData//*[vfs:attributes/vfs:docType='TAX_DOCS']

It returns nothing. Then I tried this too but no success.

//jcr:root/MyApp/documents//*[vfs:metaData/vfs:attributes/vfs:docType='TAX_DOCS']

So what am I doing wrong? Is anything in workspace.xml configuration that we need to set or missing?

Any help is appreciated.

Thanks, Jack

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

み青杉依旧 2024-11-25 17:53:42

删除除最后一个路径组件之外的任何内容中的双斜线,并使用 @ 表示法作为属性值,从而导致:

/jcr:root/MyApp/documents//*[vfs:attributes/@vfs:docType='TAX_DOCS']

// 构造查找整个子树,而不是像 / 那样仅查找直接子树。 JCR 规范仅要求实现支持 // 构造作为 XPath 查询的最后一步。

Drop the double slashed from anything but the last path component and use the @ notation for the attribute value, resulting in:

/jcr:root/MyApp/documents//*[vfs:attributes/@vfs:docType='TAX_DOCS']

The // construct looks for the whole subtree instead of just the immediate children like / does. The JCR specification only requires implementations to support the // construct as the last step of the XPath query.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文