我使用DataImporter索引MySQL记录,但每当我在浏览器上运行时,它都会给我这个错误。
HTTP ERROR 500
Problem accessing /solr/. Reason:
{msg=SolrCore 'collection1' is not available due to init failure: Unknown FieldType: 'string' used in QueryElevationComponent,trace=org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Unknown FieldType: 'string' used in QueryElevationComponent
at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:785)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:295)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:195)
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(Thread.java:724)
Caused by: org.apache.solr.common.SolrException: Unknown FieldType: 'string' used in 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:524)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:559)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:249)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:241)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
... 1 more
Caused by: org.apache.solr.common.SolrException: Unknown FieldType: 'string' used in QueryElevationComponent
at org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:169)
at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:601)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:829)
... 13 more
,code=500}
这是我的Schema.xml文件。这很简单,因为我只是SOLR的初学者。
<schema name="example" version="1.5">
<types>
<fieldtype name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0" />
<fieldtype name="text" class="solr.TextField" sortMissingLast="true" omitNorms="true" />
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
</types>
<fields>
<field name="user_id" type="text" indexed="true" stored="true" required="true" />
<field name="user_name" type="text" indexed="true" stored="false" />
<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
</fields>
<uniqueKey>user_id</uniqueKey>
</schema>
这是我的db-data-config.xml。
<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/solr_user"
user="root"
password="waseem"
batchSize="-1" />
<document name="user">
<entity name="user" query="SELECT user_id, user_name FROM users">
<field column="user_id" name="id" />
<field column="user_name" name="name" />
</entity>
</document>
</dataConfig>
任何人都可以告诉我上面的代码有什么问题以及为什么我会收到此错误。任何帮助,将不胜感激。我在Ubuntu上使用jetty。
答案 0 :(得分:0)
将您的text
类型重命名为string
,如
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
将修复错误消息,但我强烈建议重用现有的solr示例schema.xml
,并根据需要编辑字段。
如果您不包含使用分析器和过滤器的复杂类型的字段,您将无法从Solr搜索中受益。
答案 1 :(得分:0)
在以下行中,“column”应与查询中的列名相同,“name”是您要使用的名称。名称应与schema.xml
匹配 <field column="user_id" name="id" />
您需要在schema.xml中进行此更改。 schema.xml中字段的名称应与data-config.xml中的字段名称相同。
<fields>
<field name="id" type="text" indexed="true" stored="true" required="true" />
<field name="name" type="text" indexed="true" stored="false" />
</fields>
我在你的SQL查询中没有看到任何版本字段,所以我不知道你在这里尝试使用的是什么。
希望这有帮助。