JCR OAK Query & NodeType

纵然是瞬间 提交于 2019-12-12 05:43:00

问题


I am working on Apache JackRabbit OAK (1.3.2). I have created a node (MyNode) with the following structure and saved in the repository.
-- 'jcr:primaryType'=oak:Unstructured
-- 'name'='myNode'
I also created a lucene index to index all the properties as per the documentation. However when i run the following query i get no results.
select * from [oak:Unstructured] where name='myNode'
And when the run the following query i get the saved 'MyNode' in result
'select * from [nt:base] where [jcr:primaryType]='oak:Unstructured' and name='myNode''

  1. Why am i not able to query with [oak:Unstructured], when this is declared nodeType
  2. How do i verify if i am able to leverage the lucene index created?


Thanks


回答1:


Why am i not able to query with [oak:Unstructured], when this is declared nodeType

The reason I was not able to query was during the creation of the node, just setting the property 'jcr:primaryType' to 'oak:Unstructured' is not enough. We need to set the type of this property to "NAME" explicitly, else it will be treated as a "STRING" property.

How do i verify if i am able to leverage the lucene index created?

Just creating the index node will not satisfy for indexing, we also need to initialize the repository with indexing. I used the following line to enable indexing in my repository.

      jcr.withAsyncIndexing();


来源:https://stackoverflow.com/questions/32457605/jcr-oak-query-nodetype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!