简体   繁体   English

如何在Alfresco中按d:date属性启用高级搜索?

[英]How to enable advanced search by d:date properties in Alfresco?

I have a custom content model I created for Alfresco that has type with ad:date property. 我有一个为Alfresco创建的自定义内容模型,该模型的类型为ad:date属性。 I am able to build the repository and share projects with seemingly no errors. 我能够构建存储库并共享项目,看似没有任何错误。 However, I am unable to search by the properties using the data type d:date or d:int. 但是,我无法使用数据类型d:date或d:int来按属性搜索。 I resolved the d:int problem by changing the data type to d:text and adding a regex constraint, but I'm not sure if that would be prudent for the d:date property. 我通过将数据类型更改为d:text并添加了正则表达式约束来解决了d:int问题,但是我不确定d:date属性是否明智。

Is there some additional configuration that I need to supply or create in order to search by properties that are not d:text? 为了搜索不是d:text的属性,是否需要提供或创建一些其他配置?

Here is a snippet showing the type declaration: 这是显示类型声明的代码段:

<types>
    <!-- Enterprise-wide generic document type -->
    <type name="gl:x">
        <title>Document</title>
        <parent>cm:content</parent>
        <properties>
            <property name="gl:period">
                <type>d:text</type>
            </property>
            <property name="gl:year">
                <type>d:text</type>
                <constraints>
                    <constraint ref="gl:documentYears" />
                </constraints>
            </property>
            <property name="gl:docType">
                <type>d:text</type>
                <constraints>
                    <constraint ref="gl:documentTypeList" />
                </constraints>
            </property>
            <property name="gl:date">
                <type>d:date</type>
            </property>
        </properties>
    </type>
</types>

The share search forms and properties forms seem to be rendering correctly, so I don't think that there is any problem within those. 共享搜索表单和属性表单似乎正确呈现,因此我认为这些表单中没有任何问题。

The advanced search page accepts two types of parameters. 高级搜索页面接受两种类型的参数。

One is simply the "keywords" field. 一种就是“关键字”字段。 This performs a full text search, ie it looks for the provided keywords in ANY text property. 这将执行全文搜索,即在ANY文本属性中查找提供的关键字。 There is no need to configure the full text search for custom types (eg your gl:x) - it automatically picks up any text property in any model in the system. 无需为自定义类型(例如您的gl:x)配置全文搜索-它会自动选择系统中任何模型中的任何text属性。

The other is the group of single parameters: name, title, description, mime-type, modified-date, modifier. 另一个是一组单个参数:名称,标题,描述,mime类型,修改日期,修饰符。 These properties can be of any type. 这些属性可以是任何类型。 A d:date property would be perfectly acceptable here, as the modified-date parameter testifies. d:date属性在这里是完全可以接受的,因为Modifyed-date参数证明了这一点。 But here custom properties are not picked-up automatically. 但是,此处的自定义属性不会自动获取。 They need to be configured explicitly. 它们需要显式配置。

Notice that in the upper part of the advanced search page is a drop-down called "Look for" with two options: content and folders. 请注意,在高级搜索页面的上部是一个名为“查找”的下拉菜单,其中有两个选项:内容和文件夹。 The best approach would be to add an option for your content type gl:x and to configure a search form for it. 最好的方法是为您的内容类型gl:x添加一个选项,并为其配置搜索表单。

You can find the definition of the two standard search forms in tomcat/webapps/share/WEB-INF/classes/alfresco/share-form-config.xml. 您可以在tomcat / webapps / share / WEB-INF / classes / alfresco / share-form-config.xml中找到这两种标准搜索形式的定义。 The file is rather long so here are the two sections to look for: 该文件相当长,因此这里有两个要查找的部分:

<config evaluator="model-type" condition="cm:content">
  <forms>
     <!-- Default Create Content form -->
     <form>
     </form>
     <!-- Document Library Create Google Doc form -->
     <form id="doclib-create-googledoc">
     </form>
     <!-- Search form -->
     <form id="search">
     </form>
  </forms>
</config>

<!-- cm:folder type (creating nodes) -->
<config evaluator="model-type" condition="cm:folder">
  <forms>
     <!-- Document Library Common form -->
     <form id="doclib-common">
     </form>
     <!-- Search form -->
     <form id="search">
     </form>
  </forms>
</config>

I've skipped the details, but what is important is that "cm:content" and "cm:folder" each defines a <form id="search"> with the desired search properties/parameters. 我已经跳过了细节,但是重要的是,“ cm:content”和“ cm:folder”各自定义了具有所需搜索属性/参数的<form id="search">

As an experiment you could modify share-form-config.xml directly and add your own definition: 作为实验,您可以直接修改share-form-config.xml并添加自己的定义:

<config evaluator="model-type" condition="gl:x">
  <forms>
     <!-- Search form -->
     <form id="search">
        <field-visibility>
           <show id="gl:date" />
        </field-visibility>
        <appearance>
           <field id="gl:date">
              <control template="/org/alfresco/components/form/controls/daterange.ftl" />
           </field>
        </appearance>
     </form>
  </forms>
</config>

Also you have to add the new search form to the AdvancedSearch configuration found in tomcat/webapps/share/WEB-INF/classes/alfresco/share-config.xml: 另外,您还必须将新的搜索表单添加到tomcat / webapps / share / WEB-INF / classes / alfresco / share-config.xml中找到的AdvancedSearch配置中:

<config evaluator="string-compare" condition="AdvancedSearch">
  <advanced-search>
     <forms>
        <form labelId="search.form.label.cm_content" descriptionId="search.form.desc.cm_content">cm:content</form>
        <form labelId="search.form.label.cm_folder" descriptionId="search.form.desc.cm_folder">cm:folder</form>
        <form labelId="search.form.label.gl_x" descriptionId="search.form.desc.gl_x">gl:x</form>
     </forms>
  </advanced-search>
</config>

Remember to restart alfresco after every change. 请记住,每次更改后都要重新启动户外。 When you're satisfied with the results, it would be better to move your custom definitions to a separate share-config-custom.xml in your project (share-config.xml and share-form-config.xml should never be modified directly). 当您对结果感到满意时,最好将自定义定义移动到项目中的单独的share-config-custom.xml中(share-config.xml和share-form-config.xml永远不要直接修改。 )。

For more details: https://wiki.alfresco.com/wiki/Share_Advanced_Search 有关更多详细信息: https : //wiki.alfresco.com/wiki/Share_Advanced_Search

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM