2017-03-20 22 views
0

나는이 JCR SQL2 쿼리 실행 해요 :잭 래빗 오크 인덱싱

SELECT * FROM [my:type] AS n 
WHERE NAME(n) LIKE 'node_name_prefix.%' 
AND n.deleted = CAST('false' AS BOOLEAN) 
AND CONTAINS(n.user, '1f12f97d-6516-48b9-ae75-47d17ef6877f') 
AND CONTAINS(n.state, 'executing') 
OR CONTAINS(n.state, 'done') 

을 내가 지표 만들어야합니다 경고 얻을 : 같은 내가 한

Traversed 1000 nodes with filter Filter(query=SELECT * FROM [my:type] AS n 
WHERE NAME(n) LIKE 'node_name_prefix.%' AND n.deleted = CAST('false' AS 
BOOLEAN) AND CONTAINS(n.user, '1f12f97d-6516-48b9-ae75-47d17ef6877f') AND 
CONTAINS(n.state, 'executing') OR CONTAINS(n.state, 'done') 
fullText=user:"1f12f97d-6516-48b9-ae75-47d17ef6877f" (state:"executing" OR 
state:"done"), path=*, property=[:localname=[(node_name_prefix.%..], 
deleted=[false], state=[is not null]]); consider creating an index or 
changing the query 

:

NodeBuilder rootBuilder = this.segmentNodeStore.getRoot().builder(); 
NodeBuilder index = IndexUtils.getOrCreateOakIndex(rootBuilder); 
NodeBuilder childNode = index.getChildNode(propertyName); 
IndexUtils.createIndexDefinition(index, propertyName, true, uniqueValue, ImmutableList.of(propertyName), null); 
CommitHook hook = new CompositeHook(new ConflictHook(JcrConflictHandler.createJcrConflictHandler()), new EditorHook(new ConflictValidatorProvider())); 

try 
{ 
    this.segmentNodeStore.merge(rootBuilder, hook, CommitInfo.EMPTY); 
} 
catch(CommitFailedException ex) 
{ 
    throw new IOException(ex); 
} 

여기서 propertyName은 다음 문자열 중 하나입니다. deleted, state, jcr : localname, jcr : path, jcr : property, jcr : fullText, property, localname, 경로, 사용자, fullText

그러나 나는 아직도 내 색인이 사용되지 않을 것이라는 것을 추측하는 그 경고를 받는다. 사용 가능한 모든 색인을 인쇄하면 다음과 같이 표시됩니다.

사용 가능한 색인 : 삭제됨, repMembers, 카운터, 상태, jcr : 로컬 이름, jcr : 경로, acPrincipalName, jcr : 속성, jcr : fullText, uuid, 속성, localname , NODETYPE이, 참조,의 PrincipalName, 경로, 사용자, authorizableId, 전체 텍스트가

그래서 내 인덱스가 NODETYPE 같은 일부 JCR 기본 인덱스가 이미 존재하는 같은 장소에서 만들어지는 것, acPrincipalName, 참조, repMembers, authorizableId 및 카운터

여기에 내가 뭘 잘못하고 있는지 알려주시겠습니까? 쿼리가 최대한 빨리 수행되도록하기 위해 실제로 오크에서 사용할 인덱스를 만드는 방법을 알고 싶습니다. 다음과 같이 인덱스 :

this.fileStore = FileStore.builder(new File("/path/to/my/repo")).withCacheSize(512).withMemoryMapping(true).build(); 
this.segmentNodeStore = SegmentNodeStore.builder(this.fileStore).build(); 
this.repository = new Jcr(new Oak(this.segmentNodeStore)).with(qes).withAsyncIndexing().createRepository(); 

답변

1

위의 쿼리에 따르면, 당신이 lucene property index에서/오크를 만들어야합니다

나는 오크 버전 1.5.12을 사용하고 내 저장소는 다음과 같이 인스턴스화

<?xml version="1.0" encoding="UTF-8"?> 
<jcr:root xmlns:my="TYPE THE MY TYPE DEFINITION URI" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" 
    jcr:primaryType="oak:Unstructured" 
    indexDescription="My Index Defition" 
    compatVersion="{Long}2" 
    type="lucene" 
    async="async"> 
    <indexRules jcr:primaryType="nt:unstructured"> 
     <my:type 
     jcr:primaryType="nt:unstructured" 
     indexNodeName="{Boolean}true"> 
     <properties jcr:primaryType="nt:unstructured"> 
      <deleted name="deleted" propertyIndex="{Boolean}true" type="Boolean" jcr:primaryType="nt:unstructured"/> 
      <user name="user" analyzed="{Boolean}true" nodeScopeIndex="{Boolean}true" jcr:primaryType="nt:unstructured"/> 
      <state name="state" analyzed="{Boolean}true" nodeScopeIndex="{Boolean}true" jcr:primaryType="nt:unstructured"/> 
     </properties> 
     </my:type> 
    </indexRules> 
</jcr:root> 

설명 :

+ myCustomIndex 
    - type = "lucene" -> tells that your are defining lucene index 
    - async = "async" -> should be alsways set to "async" according the docs 
    + indexRules -> defines the rules for this index 
    + my:type -> defines the index rules for your custom node type 
     - indexNodeName = "true" -> indexes the node name and make "like" queries possible 
     + properties -> the index rules for the properties on your my:type node 
     + deleted 
      - name = "deleted" -> property name 
      - propertyIndex = "true" -> controls if this property is used for equality conditions 
      - type = "Boolean" -> property type 
     + user 
      - name = "user" -> property name 
      - analyzed = "true" -> when used as part of contains 
      - nodeScopeIndex = "Boolean" -> control whether the value of a property should be part of fulltext index 
     + state 
      - name = "state" -> property name 
      - analyzed = "true" -> when used as part of contains 
      - nodeScopeIndex = "Boolean" -> control whether the value of a property should be part of fulltext index 
+0

감사 보라 (여기 설명) (https://gist.github.com/chetanmeh/c1ccc4fa588ed1af467b)의 코드 예제와 함께 필요한 색인을 만들 수있었습니다. – funfried