SOLR uniqueKey与solr.UUIDField

时间:2014-02-12 18:31:28

标签: solr dataimporthandler unique-key

尝试使用solr.UUIDField生成uniqueKey字段。

<fieldType name="uuid" class="solr.UUIDField" indexed="true" />


<field name="uid" type="uuid" indexed="true" stored="true" default="NEW" />

<uniqueKey>uid</uniqueKey>

但由于某种原因,它不起作用。

错误讯息:

  

{msg =由于init失败,SolrCore'db'不可用:uniqueKey字段(null)无法配置默认值(NEW)。模式文件是。\ example-DIH \ solr \ db \ schema.xml,trace = org.apache.solr.common.SolrException:由于init失败,SolrCore'db'不可用:无法配置uniqueKey字段(null)使用默认值(NEW)。架构文件是。\ example-DIH \ solr \ db \ schema.xml       在org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:818)       在org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:289)       在org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:197)       在org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1419)       在org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)       在org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)       在org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)       在org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)       在org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)       在org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)       在org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)       在org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)       在org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)       at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)       在org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)       在org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)       在org.eclipse.jetty.server.Server.handle(Server.java:368)       at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)       at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)       at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)       at org.eclipse.jetty.server.AbstractHttpConnection $ RequestHandler.headerComplete(AbstractHttpConnection.java:1004)       在org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)       在org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)       at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)       在org.eclipse.jetty.server.bio.SocketConnector $ ConnectorEndPoint.run(SocketConnector.java:264)       在org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)       在org.eclipse.jetty.util.thread.QueuedThreadPool $ 3.run(QueuedThreadPool.java:543)       在java.lang.Thread.run(未知来源)   引起:org.apache.solr.common.SolrException:uniqueKey字段(null)不能配置默认值(NEW)。架构文件是。\ example-DIH \ solr \ db \ schema.xml       在org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:608)       在org.apache.solr.schema.IndexSchema。(IndexSchema.java:166)       在org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55)       在org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69)       在org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:554)       在org.apache.solr.core.CoreContainer.create(CoreContainer.java:592)       在org.apache.solr.core.CoreContainer $ 1.call(CoreContainer.java:271)       在org.apache.solr.core.CoreContainer $ 1.call(CoreContainer.java:263)       at java.util.concurrent.FutureTask $ Sync.innerRun(Unknown Source)       at java.util.concurrent.FutureTask.run(Unknown Source)       at java.util.concurrent.Executors $ RunnableAdapter.call(Unknown Source)       at java.util.concurrent.FutureTask $ Sync.innerRun(Unknown Source)       at java.util.concurrent.FutureTask.run(Unknown Source)       at java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(Unknown Source)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source)       ......还有1个   引起:org.apache.solr.common.SolrException:uniqueKey字段(null)无法配置默认值(NEW)       在org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:536)

更新

在我做出了答案中的leoh建议的更改后,我收到了以下错误消息:

我也忘了提到它在使用dataimporthandler时我收到了错误信息。

{msg=SolrCore 'db' is not available due to init failure: Error initializing QueryElevationComponent.,trace=org.apache.solr.common.SolrException: SolrCore 'db' is not available due to init failure: Error initializing QueryElevationComponent.
at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:818)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:289)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:197)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:368)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.solr.common.SolrException: Error initializing QueryElevationComponent.
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:834)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:625)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:557)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:592)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:271)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:263)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
... 1 more
Caused by: org.apache.solr.common.SolrException: Error initializing QueryElevationComponent.
at org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:242)
at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:631)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:829)
... 13 more
Caused by: org.apache.solr.common.SolrException: Invalid UUID String: '1'
at org.apache.solr.schema.UUIDField.toInternal(UUIDField.java:89)
at org.apache.solr.schema.FieldType.readableToIndexed(FieldType.java:391)
at org.apache.solr.handler.component.QueryElevationComponent$ElevationObj.<init>(QueryElevationComponent.java:138)
at org.apache.solr.handler.component.QueryElevationComponent.loadElevationMap(QueryElevationComponent.java:311)
at org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:225)

我尝试删除以下内容,但之后没有任何内容编入索引:

<searchComponent name="elevator" class="org.apache.solr.handler.component.QueryElevationComponent" >
    <!-- pick a fieldType to analyze queries -->
    <str name="queryFieldType">string</str>
    <str name="config-file">elevate.xml</str>
</searchComponent>

2 个答案:

答案 0 :(得分:5)

David2342

要在solr 4.6中配置uuid字段,您可能需要以下配置

<!--schema.xml-->

<fieldType name="uuid" class="solr.UUIDField" indexed="true" />

<field name="id" type="uuid" indexed="true" stored="true" required="true" />

<uniqueKey>id</uniqueKey>

<!--solrconfig.xml-->
<updateRequestProcessorChain name="uuid">
    <processor class="solr.UUIDUpdateProcessorFactory">
      <str name="fieldName">id</str>
    </processor>
    <processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>


 <requestHandler name="/update" class="solr.UpdateRequestHandler">
       <lst name="defaults">
         <str name="update.chain">uuid</str>
       </lst>
</requestHandler>

以下链接指向适用于我的示例配置:https://gist.github.com/leoh/8967328

答案 1 :(得分:1)

对于第二个错误“init failure:”,您需要修改elevate.xml文件中的uid。提升文件的默认路径是

@ SOLR_HOME\example\example-DIH\solr\solr\conf 

可能你的文件路径可能不同。

如果您想知道elevate.xml文件的确切位置,请附上您的elevate.xml文件。