2013-03-07 94 views
1

數據config.xml的是如下Solr的數據導入處理程序無法索引數據

<dataConfig> 
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/solrdata" user="root" password="root" /> 
    <document name="cars"> 

     <entity name="car" query="SELECT color FROM solrdata.car "> 

      <field column="color" name="color" /> 

     </entity> 

    </document> 
</dataConfig> 

schema.xml中是follsws

field name="color" type="string" indexed="true" stored="true" /> 

我在調試模式下檢查其獲得的數據,但不能處理它

的調試模式輸出如下所示:

{ 
    "responseHeader": { 
    "status": 0, 
    "QTime": 312 
    }, 
    "initArgs": [ 
    "defaults", 
    [ 
     "config", 
     "data-config.xml" 
    ] 
    ], 
    "command": "full-import", 
    "mode": "debug", 
    "documents": [ 
    { 
     "COLOR": [ 
     "red" 
     ] 
    }, 
    { 
     "COLOR": [ 
     "silver" 
     ] 
    }, 
    { 
     "COLOR": [ 
     "oii" 
     ] 
    } 
    ], 
    "verbose-output": [], 
    "status": "idle", 
    "importResponse": "", 
    "statusMessages": { 
    "Total Requests made to DataSource": "1", 
    "Total Rows Fetched": "3", 
    "Total Documents Skipped": "0", 
    "Full Dump Started": "2013-03-07 15:49:14", 
    "Total Documents Processed": "0", 
    "Total Documents Failed": "3", 
    "Time taken": "0:0:0.281" 
    }, 
    "WARNING": "This response format is experimental. It is likely to change in the future." 
} 
+0

你在你的schema.xml中有一個「唯一鍵」字段?你如何爲每個被索引的文檔構造它? – Mavellin 2013-03-07 11:12:05

+0

我是solr的新手,我在現有的schema.xml中添加了這個字段。 – 2013-03-07 11:17:49

回答

3

對於每個文檔,您將擁有一個uniqueKey以唯一標識它(可以認爲類似於數據庫中的PrimaryKey)。

修改你的實體數據-config.xml中如下:

<entity name="car" query="SELECT color,id FROM solrdata.car "> 

    <field column="id" name="id" /> 
    <field column="color" name="color" /> 

</entity> 

注: ID字段是表車的的PrimaryKey

在你的Schema.xml文件,添加以下行,

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

此外,請確保以下的文字,

<uniqueKey>id</uniqueKey> 

在schema.xml中沒有被註釋掉。

現在,重新啓動您的Solr Web應用程序並執行完全導入。

+0

在您的示例中,''中的''元素不是必需的,因爲列名和「字段」名稱相同。 – 2013-03-07 22:20:06

3

我可以從導入處理程序響應閱讀:

"Total Documents Failed": "3" 

看起來對我來說,就好像您的查詢也存在一些問題,或者如果加載的架構不「匹配」的DIH輸出中。儘管強烈建議,但不需要字段<uniqueKey>。但缺少的唯一密鑰聲明應該導致該錯誤。

查看管理控制檯上的「日誌記錄」頁面。如果數據導入處理程序對查詢有問題,那麼您會在那裏找到一個日誌條目。

如果您在solr實例運行時應用了任何更改,請不要忘記刷新架構和DIH配置文件。

0

某些特定字段(包括版本)不應位於您的字段列表中。 (FL =「*」,這是包含了所有領域) 逐一嘗試字段對應的ID

FL =「標識,色」

相關問題