0

我有一个关于通过inputStream名为 data 的类型的属性来过滤资源的 xpath 表达式的问题。如何进行文本搜索,例如这是有效的:

String xpath1 = "<my app path>//element(*, nt:resource) [jcr:contains(@jcr:mimeType,'*plain*')]";
String xpath2 = "<my app path>//element(*, nt:resource) [jcr:contains(@jcr:encoding,'*utf*')]";

但这不起作用。

String xpath3 = "<my app path>//element(*, nt:resource) [jcr:contains(@jcr:data,'*plain*')]";

真正的事实是我们使用了一些自定义节点,让我们解释一下属性定义:

在 Java 术语中...

public class Resource extends BaseNode {

  /** Encoding media type. It cannot be null or empty. */
  @Field(jcrName = "jcr:encoding", jcrDefaultValue = "")
  private String encoding;

  /** Resource's MIME type. It cannot be null or empty. */
  @Field(jcrName="jcr:mimeType", jcrDefaultValue = "")
  private String mimeType;

  /** Resource's size (bytes). */
  @Field(jcrName="skl:size")
  private long size;

  /** Resource's content data as stream. It cannot be null. */
  @Field(jcrName="jcr:data")
  private InputStream data;

  ...
}

@Node(jcrType = "baseNode", isAbstract = true)
public abstract class BaseNode {

  @Field(jcrName = "name", id = true)
  protected String name;

  @Field(jcrName = "creationDate")
  protected Date creationDate;

  ...
}

在 JackRabbit 术语中......

<!-- Base node type definition -->
  <nodeType name="docs:baseNode"
            isMixin="false"
            hasOrderableChildNodes="false" >
    <supertypes>
      <supertype>nt:hierarchyNode</supertype>
    </supertypes>
    <propertyDefinition name="docs:name"
                        requiredType="String"
                        autoCreated="false"
                        mandatory="true"
                        onParentVersion="COPY"
                        protected="false"
                        multiple="false" />
    <propertyDefinition name="docs:searchPath"
                        requiredType="String"
                        autoCreated="false"
                        mandatory="false"
                        onParentVersion="COPY"
                        protected="false"
                        multiple="false" />
    <propertyDefinition name="docs:creationDate"
                        requiredType="Date"
                        autoCreated="false"
                        mandatory="true"
                        onParentVersion="COPY"
                        protected="false"
                        multiple="false" />
    <propertyDefinition name="docs:lastModified"
                        requiredType="Date"
                        autoCreated="false"
                        mandatory="true"
                        onParentVersion="COPY"
                        protected="false"
                        multiple="false" />
    <childNodeDefinition name="*"
                         defaultPrimaryType="docs:baseNode"
                         autoCreated="false"
                         mandatory="false"
                         onParentVersion="COPY"
                         protected="false"
                         sameNameSiblings="false">
      <requiredPrimaryTypes>
        <requiredPrimaryType>docs:baseNode</requiredPrimaryType>
      </requiredPrimaryTypes>
    </childNodeDefinition>
  </nodeType>


  <!-- Resource node type definition -->
  <nodeType name="skl:resource"
            isMixin="false"
            hasOrderableChildNodes="false" >
    <supertypes>
      <supertype>docs:baseNode</supertype>
      <supertype>nt:resource</supertype>
    </supertypes>
    <propertyDefinition name="skl:size"
                        requiredType="Long"
                        autoCreated="false"
                        mandatory="true"
                        onParentVersion="COPY"
                        protected="false"
                        multiple="false" />
    <propertyDefinition name="skl:externalUri"
                        requiredType="String"
                        autoCreated="false"
                        mandatory="false"
                        onParentVersion="COPY"
                        protected="false"
                        multiple="false" />
  </nodeType>

关键是,我如何执行此查询以按 jcr:data 属性进行过滤。

4

1 回答 1

0

我认为您必须打开文本提取,以便您的“jcr:data”属性中的可搜索文本将被索引。在 Jackrabbit 讨论列表中查看此电子邮件主题。

顺便说一句,JCR CND 格式是描述节点类型的更紧凑的方式。

于 2012-07-16T21:12:36.217 回答