当前位置: 首页 > 知识库问答 >
问题:

大白兔橡树

葛安和
2023-03-14

我正在执行这个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、path、user、fullText

但我还是得到了警告,我想这意味着我的指数不会被使用。当我打印出所有可用的索引时,我得到以下信息:

可用的索引:已删除,repp成员,计数器,状态,jcr: localname,jcr: path,acPrindalName,jcr:属性,jcr: FullText,uuid,属性,localname,nodetype,引用,主体名称,路径,用户,授权的ableId,FullText

因此,我的索引似乎是在一些jcr默认索引已经存在的相同地方创建的,如nodetype、acPr的名称、引用、rep的成员、授权的ID和计数器

有什么提示我做错了吗?我只想确保查询尽可能快,所以我真的很想知道如何创建橡木使用的索引。

我使用的是橡树1.5版。12我的存储库是这样实例化的:

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个答案

文嘉禧
2023-03-14

根据您上面的查询,您应该在 /oak: index下创建一个Lucene属性索引,如下所示:

<?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
 类似资料:
  • 在XML文件中配置RabbitMQ时,我试图理解Spring RabbitMQ代码。在接收方xml文件中,我有 我的问题是-交换绑定到哪个队列??springQueue或spring。队列我的意思是,在标签中,它是指队列id还是队列名称??同样在标签中,“队列”属性指的是队列id或队列名称??请帮忙。我查看了模式(xsd),但没有弄清楚。请帮忙。

  • 黑白棋大师,是一个安卓棋类游戏。黑白棋,又叫苹果棋,最早流行于西方国家。游戏通过相互翻转对方的棋子,最后以棋盘上谁的棋子多来判断胜负。黑白棋非常易于上手,但精通则需要考虑许多因素,比如角边这样的特殊位置、稳定度、行动力等。本游戏取名为黑白棋大师,提供了8种难度等级的选择,从菜鸟、新手、入门、棋手到棋士、大师、宗师、棋圣,助你不断提升棋力。

  • 概述 一体化橡胶履带的内部具有同步带齿,使轨道能够与Makeblock 90T和62T履带轮一起配合工作。 参数 材质:黑色硅胶

  • 我的设置面临一些问题,我正在尝试增加心跳间隔,以测试可能的修复。我正在使用 下面是实例化连接工厂的代码 问题是心跳间隔没有改变。我在AMQConnection中快速查看以下内容 来自服务器的值是60。方法negotiatedMaxValue将不尊重客户端的首选项(不能禁用心跳信号,也不能增加心跳信号)。我错过什么了吗?

  • 我们正在使用spring云配置服务器。Spring配置客户端使用Spring控制总线(RabbitMQ)获取更新。 看起来每个配置客户端实例都会创建一个连接到'spring.cloud.bus'交换的队列。 对有多少应用程序实例可以连接到“spring.cloud.bus”交换有任何可伸缩性限制? 我想RabbitMQ可以扩展来处理这个问题。 寻找这方面的指导方针。 许多感谢,

  • 是否可以使用RabbitMQ主题交换实现以下场景。 假设我有两个队列: 队列1:路由关键字MainRoute。路线1 Queue2:路由密钥MainRoute.Route2 使用路由密钥发布邮件时: 主要路线。路线1- 主干道。路线2 - 主要路线- 是否可以实现这一点,而不需要实施一些特殊的过滤、路由过程? 如果没有,你能建议一个可能的解决方案吗? 谢谢你。