Alfresco搜索页,按自定义属性排序未索引错误

Alfresco搜索页,按自定义属性排序未索引错误,alfresco,solr4,Alfresco,Solr4,当我尝试按自定义属性排序时,Alfresco搜索页面中出现错误: 环境: 露天5.0.1 博士后 Solr4 雄猫7 错误: 2015-05-12 12:54:34,864 ERROR [solr.core.SolrCore] [http-bio-8443-exec-7] org.apache.solr.common.SolrException: sort param could not be parsed as a query, and is not a field that exists

当我尝试按自定义属性排序时,Alfresco搜索页面中出现错误:

环境:

  • 露天5.0.1
  • 博士后
  • Solr4
  • 雄猫7
  • 错误:

    2015-05-12 12:54:34,864  ERROR [solr.core.SolrCore] [http-bio-8443-exec-7] org.apache.solr.common.SolrException: sort param could not be parsed as a query, and is not a field that exists in the index: @{http://global.oup.com/dam/model/1.0}supplierName
            at org.apache.solr.search.QueryParsing.parseSortSpec(QueryParsing.java:358)
            at org.alfresco.solr.query.AbstractQParser.getSort(AbstractQParser.java:569)
            at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:175)
            at org.apache.solr.handler.component.AlfrescoSearchHandler.handleRequestBody(AlfrescoSearchHandler.java:233)
            at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
            at org.apache.solr.core.SolrCore.execute(SolrCore.java:1962)
            at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:777)
            at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:418)
            at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:207)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
            at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
            at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
            at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
            at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
            at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
            at java.lang.Thread.run(Thread.java:744)
    Caused by: org.apache.solr.search.SyntaxError: Expected identifier at pos 0 str='@{http://global.oup.com/dam/model/1.0}supplierName desc'
            at org.apache.solr.search.QueryParsing$StrParser.getId(QueryParsing.java:770)
            at org.apache.solr.search.QueryParsing$StrParser.getId(QueryParsing.java:749)
            at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:345)
            at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:68)
            at org.apache.solr.search.QParser.getQuery(QParser.java:141)
            at org.apache.solr.search.QueryParsing.parseSortSpec(QueryParsing.java:286)
            ... 25 more
    
    我的自定义字段在内容模型文件中配置如下:

    <types>
         <type name="oup:asset">
             <title>Asset</title>
             <parent>ipp:asset</parent>
    
             <property name='oup:supplierName'>
                  <title>Supplier Name</title>
                   <description>Name of the supplier (note there is also a supplier
                            specified on asset rights)
                   </description>
                   <type>d:mltext</type>
                   <mandatory enforced='false'>true</mandatory>
                   <multiple>true</multiple>
                   <index enabled="true">
                       <atomic>true</atomic>
                       <stored>false</stored>
                       <tokenised>both</tokenised>
                   </index>
             </property>
         </type>
    </types>
    

    有什么想法吗?

    只将
    d:mltext
    更改为
    d:text
    。如果您不需要多语言支持,有时d:mltext会产生问题

    也许下面的人会帮助你

    Atomic=“true”
    如果为true,则在事务中为属性编制索引,如果不是,则在后台为属性编制索引。 如果转换花费的时间少于为lucene.maxAtomicTransformationTime指定的值,则在索引之前需要转换的内容(例如PDF)的索引将只服从Atomic=true

    lucene.maxAtomicTransformationTime=20 可能需要更长时间(以毫秒为单位)的内容转换将在后台完成。若要强制建立原子内容索引,请增加此值

    你一定知道


    SOLR不在事务索引中执行。我发现了问题,这是Solr4错误/行为,当它尝试对多个属性(如Alfresco多值属性)进行排序时-

    我在Solr web应用程序中发现了以下代码:

    private void addSortSearchFields( PropertyDefinition propertyDefinition , IndexedField indexedField)
    {
        // Can only order on single valued fields
        DataTypeDefinition dataTypeDefinition = propertyDefinition.getDataType();
        if(dataTypeDefinition.getName().equals(DataTypeDefinition.TEXT))
        { 
            if(propertyDefinition.isMultiValued() == false)
            {
                if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE)
                        || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH))
                {
                    indexedField.addField(getFieldForText(false, false, true, propertyDefinition), false, true);
                }
                else if (isIdentifierTextProperty(propertyDefinition.getName()))
                {
                    indexedField.addField(getFieldForText(false, false, false, propertyDefinition), false, false);   
                }
                else
                {
                    indexedField.addField(getFieldForText(false, true, false, propertyDefinition), false, false);
                }
            }
        }
    
        if(dataTypeDefinition.getName().equals(DataTypeDefinition.MLTEXT))
        {
            if(propertyDefinition.isMultiValued() == false)
            {
                if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE)
                        || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH))
                {
                    indexedField.addField(getFieldForText(false, false, true, propertyDefinition), false, true);
                }
                else
                {
                    indexedField.addField(getFieldForText(false, true, false, propertyDefinition), false, false);
                }
            }
        }
    }
    
    因此,只有当
    propertyDefinition.isMultiValue()==false
    时,它才会进行排序,然后在代码中稍后抛出异常,因为它无法映射QName

    是这样吗

    有没有办法不用编码就跳过它

    如果没有,我认为唯一的解决方法是以某种方式覆盖Springbean以使用我们的自定义函数,有没有建议在不部署Solr的情况下这样做

    或者可能是春季AOP,但老实说,我不喜欢这个主意

    有可能的解决方案吗?

    我找到了一个解决方案:

    • 在内容模型中创建一个新属性,即文本。这是多值字段的字符串表示形式,也被索引

    • 使用两个策略创建一个行为:onUpdatePolicy和onCreatePolicy,用于表示多值字段的字符串

    • 创建一个补丁(Springbean),为所有旧内容的新字段设置值

    该字段对于所有UI都是隐藏的,用户无法设置该字段。 它被索引以使分面搜索在alfresco 5中工作并进行排序


    所描述的解决方案是我找到的最好的,希望能有所帮助。欢迎您提出任何建议。

    您尝试过我的解决方案吗?我尝试过您的解决方案,但这不是问题所在。主要问题是
    true
    。另外,我读了这篇文章:docs.alfresco.com/5.0/concepts/search-fts-config.html,对于alfresco 5,似乎还有另一个用于刻面搜索的标记,我需要实现它,但它似乎不适用于
    true
    我尝试了您的解决方案,但这不是问题所在。主要问题是
    true
    。另外,我读了这篇文章:,对于Alfresco 5,似乎有另一个用于刻面搜索的标记,我需要实现它,但它似乎不适用于
    true
    ,因此,如果我删除
    true
    行,类型d:mltext的属性工作得很好,Solr4能够通过具有相同配置的自定义属性对内容进行排序。那么,这是一只露天5号臭虫吗?或者在Alfresco 5中是否有其他方法来配置要由Solr 4索引的多值属性?我找到了一个解决方法,正如您在第三个答案中看到的代码一样,Solr 4不提供查看代码的多值字段排序。老实说,这是一种非常奇怪的行为:/
    private void addSortSearchFields( PropertyDefinition propertyDefinition , IndexedField indexedField)
    {
        // Can only order on single valued fields
        DataTypeDefinition dataTypeDefinition = propertyDefinition.getDataType();
        if(dataTypeDefinition.getName().equals(DataTypeDefinition.TEXT))
        { 
            if(propertyDefinition.isMultiValued() == false)
            {
                if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE)
                        || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH))
                {
                    indexedField.addField(getFieldForText(false, false, true, propertyDefinition), false, true);
                }
                else if (isIdentifierTextProperty(propertyDefinition.getName()))
                {
                    indexedField.addField(getFieldForText(false, false, false, propertyDefinition), false, false);   
                }
                else
                {
                    indexedField.addField(getFieldForText(false, true, false, propertyDefinition), false, false);
                }
            }
        }
    
        if(dataTypeDefinition.getName().equals(DataTypeDefinition.MLTEXT))
        {
            if(propertyDefinition.isMultiValued() == false)
            {
                if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE)
                        || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH))
                {
                    indexedField.addField(getFieldForText(false, false, true, propertyDefinition), false, true);
                }
                else
                {
                    indexedField.addField(getFieldForText(false, true, false, propertyDefinition), false, false);
                }
            }
        }
    }