Solr Data-config.xml和mysql-我只能加载;id";柱
我在WindowsServer2012上安装了Solr5.0.0。我想将表中的所有数据加载到solr引擎中 我的data-config.xml如下所示:Solr Data-config.xml和mysql-我只能加载;id";柱,solr,lucene,dataimporthandler,Solr,Lucene,Dataimporthandler,我在WindowsServer2012上安装了Solr5.0.0。我想将表中的所有数据加载到solr引擎中 我的data-config.xml如下所示: <?xml version="1.0" encoding="UTF-8" ?> <!--# define data source --> <dataConfig> <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driv
<?xml version="1.0" encoding="UTF-8" ?>
<!--# define data source -->
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/database"
user="root"
password="root"/>
<document>
<entity name="my_table"
pk="id"
query="SELECT ID, LASTNAME FROM my_table limit 2">
<field column="ID" name="id" type="string" indexed="true" stored="true" required="true" />
<field column="LASTNAME" name="lastname" type="string" indexed="true" stored="true"/>
</entity>
</document>
</dataConfig>
和原始调试响应:
{
"responseHeader": {
"status": 0,
"QTime": 280
},
"initArgs": [
"defaults",
[
"config",
"data-config.xml"
]
],
"command": "full-import",
"mode": "debug",
"documents": [
{
"id": [
1983
],
"_version_": [
1497798459776827400
]
},
{
"id": [
1984
],
"_version_": [
1497798459776827400
]
}
],
"verbose-output": [
"entity:my_table",
[
"document#1",
[
"query",
"SELECT ID,LASTNAME FROM my_table limit 2",
"time-taken",
"0:0:0.8",
null,
"----------- row #1-------------",
"LASTNAME",
"Gates",
"ID",
1983,
null,
"---------------------------------------------"
],
"document#2",
[
null,
"----------- row #1-------------",
"LASTNAME",
"Doe",
"ID",
1984,
null,
"---------------------------------------------"
],
"document#3",
[]
]
],
"status": "idle",
"importResponse": "",
"statusMessages": {
"Total Requests made to DataSource": "1",
"Total Rows Fetched": "2",
"Total Documents Skipped": "0",
"Full Dump Started": "2015-04-07 15:05:22",
"": "Indexing completed. Added/Updated: 2 documents. Deleted 0 documents.",
"Committed": "2015-04-07 15:05:22",
"Optimized": "2015-04-07 15:05:22",
"Total Documents Processed": "2",
"Time taken": "0:0:0.270"
}
}
最后当我问索尔的时候
http://localhost:8983/solr/test/query?q=*:*
我得到了一个答案:
Indexing completed. Added/Updated: 2 documents. Deleted 0 documents
Requests: 1, Fetched: 2, Skipped: 0, Processed: 2
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"*:*"}},
"response":{"numFound":2,"start":0,"docs":[
{
"id":"1983",
"_version_":1497798459776827392},
{
"id":"1984",
"_version_":1497798459776827393}]
}}
我也想看看lastname列。为什么我不能?日志中的警告实际上是真正的问题 如果查看solrconfig.xml文件,您将看到一个部分:
<schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">true</bool>
<str name="managedSchemaResourceName">managed-schema</str>
</schemaFactory>
真的
托管模式
这意味着将忽略schema.xml文件。相反,将使用同一文件夹中的文件管理架构
有几种方法可以解决这个问题。您可以注释掉托管架构部分,并将其替换为
<schemaFactory class="ClassicIndexSchemaFactory"/>
或者另一种方法是删除托管架构文件。然后,SOLR将在重新启动时读取schema.xml文件,并生成一个新的托管模式。如果这样做有效,那么您应该在文件底部看到您的字段
有关更多信息,请参阅:
Post your schema.xml看起来您正试图像通常一样在
schema.xml
中直接在data config.xml
中定义字段,我必须对其进行实验,但我认为这实际上是不可能的。数据配置.xml
中的
元素更多地是关于将返回的SQL列
映射到预期的Solr字段名称
。是否在schema.xml
中定义lastname
字段?如果查询返回的字段没有映射到定义的字段,数据导入程序通常会自动删除这些字段。谢谢您的回答!所以:1。我将data-config.xml更改为:
2。添加了一行
My schema.xml,看起来像下面这样:我在日志中得到了一个警告:managedIndexchemaFactory模式已升级为托管, 但是非托管schema.xml仍然是可加载的。请删除此文件。
在我看来,我的问题与此温暖无关,但我不能绝对肯定这一点