solr 6.2.1 uniqueField不起作用

时间:2016-10-08 12:20:09

标签: apache solr

我安装solr 6.2.1并在架构中定义一个uniqueField:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Solr managed schema - automatically generated - DO NOT EDIT -->
<schema name="ps_product" version="1.5">
  <fieldType name="int" class="solr.TrieIntField" positionIncrementGap="0" precisionStep="0"/>
  <fieldType name="long" class="solr.TrieLongField" positionIncrementGap="0" precisionStep="0"/>
  <fieldType name="string" class="solr.TextField" omitNorms="true" sortMissingLast="true"/>
  <fieldType name="uuid" class="solr.UUIDField" indexed="true"/>

  <field name="_version_" type="long" multiValued="false" indexed="true" stored="true"/>
  <field name="id_product" type="uuid" default="NEW" indexed="true" stored="true"/>
  <uniqueKey>id_product</uniqueKey>
  <field name="name" type="string" indexed="true" stored="true"/>
  <field name="title" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
</schema>

和我的数据配置如下:

<dataConfig>
    <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/pressdb-local" user="sa" password="" />
    <document>
        <entity name="item" query="select * from ps_product as p inner join ps_product_lang as pl on pl.id_product=p.id_product where pl.id_lang=2"
                deltaQuery="select id from ps_product where date_upd > '${dataimporter.last_index_time}'">
            <field name="name" column="name"/>
            <field name="id_product" column="id_product"/>

            <entity name="comment"  
                    query="select title from ps_product_comment where id_product='${item.id_product}'"
                    deltaQuery="select id_product_comment from ps_product_comment where date_add > '${dataimporter.last_index_time}'"
                    parentDeltaQuery="select id_product from ps_product where id_product=${comment.id_product}">
                <field name="title" column="title" />
            </entity>

        </entity>
    </document>
</dataConfig>

但是当我想在solr中定义一个核心时,给我一个错误:

Error CREATEing SolrCore 'product': Unable to create core [product] Caused by: QueryElevationComponent requires the schema to have a uniqueKeyField.

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

由于Solr 4和支持SolrCloud,uniqueKey字段无法再使用git push 填充,您应该从schema.xml中的feld定义中删除它:

default=...

更新:正如MatsLindh所指出的那样,您似乎在schemaless mode中使用了Solr。此模式下的架构更新必须通过Schema API完成,您不应编辑托管架构(<field name="id_product" type="uuid" indexed="true" stored="true"/>)。要定义 id_product uniqueKey 字段,请使用API​​或revert to the classic schema模式。

要为正在添加但尚未在指定字段中具有值的任何文档生成uniqueKey,您可以使用UUIDUpdateProcessorFactory(参见Update Request Processor)。您需要在solrconfig.xml中定义更新处理器链:

<!-- Solr managed schema - automatically generated - DO NOT EDIT -->

然后通过请求处理程序定义中的请求参数 <updateRequestProcessorChain name="uuid"> <processor class="solr.UUIDUpdateProcessorFactory"> <str name="fieldName">id_product</str> </processor> <processor class="solr.RunUpdateProcessorFactory" /> </updateRequestProcessorChain> 指定处理器链的使用。

相关问题