yzwj2004 发表于 2016-12-16 10:12:02

solr 设置id为自动生成的uuid

版本为solr3.5
http://wiki.apache.org/solr/UniqueKey
这里讲到如何添加uuid,具体为在schema.xml中加入:
<fieldType name="uuid" class="solr.UUIDField" indexed="true" />
<field name="id" type="uuid" indexed="true" stored="true" required="true"/>

这么设置之后, 启动报错:
QueryElevationComponent requires the schema to have a uniqueKeyField implemented using StrField
网上查了一下, 最后找到解决方案:
http://blog.chenlb.com/2009/05/apache-solr-quick-start-and-demo.html
<!-- a search component that enables you to configure the top results for
a given query regardless of the normal lucene scoring.-->
<searchComponent name="elevator" class="solr.QueryElevationComponent" >
<!-- pick a fieldType to analyze queries -->
<str name="queryFieldType">string</str>
<str name="config-file">elevate.xml</str>
</searchComponent>
<!-- a request handler utilizing the elevator component -->
<requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="echoParams">explicit</str>
</lst>
<arr name="last-components">
<str>elevator</str>
</arr>
</requestHandler>

把这些内容从solrconfig.xml中注释掉就可以了。
页: [1]
查看完整版本: solr 设置id为自动生成的uuid