2017-09-25 99 views
0

嗨我想索引mysql數據庫solr。但它唯一的索引ID。我嘗試了很多。但沒有成功。但我試圖在同一個數據庫中測試地理位置並進行測試,併成功將所有城市編入索引。我只知道什麼是錯過的。該查詢包含一些產品的描述,例如「Solr不返回從MySQL索引的結果」。Solr不索引mysql數據庫

我的數據庫配置

<entity name="geo" 
    pk="id" 
    query="select id, title from `inlive`" 
    deltaImportQuery="select id, title from `inlive`" 
    deltaQuery="select id, title from `inlive`" 
    > 
     <field column="id" name="id"/> 
     <field column="title" name="title"/> 
    </entity> 

架構

<?xml version="1.0" encoding="UTF-8" ?> 
<uniqueKey>id</uniqueKey> 
<schema name="geo" version="1.5"> 
    <field name="_version_" type="long" indexed="true" stored="true"/> 
    <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> 
    <field name="title" type="string" indexed="true" stored="true" multiValued="false" required="true" /> 
</schema> 

結果

{ 
    "responseHeader":{ 
    "status":0, 
    "QTime":3, 
    "params":{ 
     "q":"*:*", 
     "indent":"on", 
     "wt":"json", 
     "_":"1506369405758"}}, 
    "response":{"numFound":2,"start":0,"docs":[ 
     { 
     "id":"1", 
     "_version_":1579543508130201600}, 
     { 
     "id":"2", 
     "_version_":1579543508218281984}] 
    }} 

調試

{ 
    "responseHeader": { 
    "status": 0, 
    "QTime": 275 
    }, 
    "initArgs": [ 
    "defaults", 
    [ 
     "config", 
     "data-config.xml" 
    ] 
    ], 
    "command": "full-import", 
    "mode": "debug", 
    "documents": [ 
    { 
     "id": [ 
     1 
     ], 
     "_version_": [ 
     1579544391043776500 
     ] 
    }, 
    { 
     "id": [ 
     2 
     ], 
     "_version_": [ 
     1579544391046922200 
     ] 
    } 
    ], 
    "verbose-output": [ 
    "entity:geo", 
    [ 
     "document#1", 
     [ 
     "query", 
     "select id, title from `inlive`", 
     "time-taken", 
     "0:0:0.10", 
     null, 
     "----------- row #1-------------", 
     "id", 
     1, 
     "title", 
     "test title", 
     null, 
     "---------------------------------------------" 
     ], 
     "document#2", 
     [ 
     null, 
     "----------- row #1-------------", 
     "id", 
     2, 
     "title", 
     "test title 2", 
     null, 
     "---------------------------------------------" 
     ], 
     "document#3", 
     [] 
    ] 
    ], 
    "status": "idle", 
    "importResponse": "", 
    "statusMessages": { 
    "Total Requests made to DataSource": "1", 
    "Total Rows Fetched": "2", 
    "Total Documents Processed": "2", 
    "Total Documents Skipped": "0", 
    "Full Dump Started": "2017-09-25 20:21:57", 
    "": "Indexing completed. Added/Updated: 2 documents. Deleted 0 documents.", 
    "Committed": "2017-09-25 20:21:57", 
    "Optimized": "2017-09-25 20:21:57", 
    "Time taken": "0:0:0.255" 
    } 
} 
+0

你錯過'實體'結束標籤,並且您確保在更改後重新加載配置? – MatsLindh

+0

實體關閉標籤已經存在於此中。代碼編輯器錯過了關閉標籤。任何想法缺少什麼? –

+0

我發現了這個問題。當我使用 它的索引。但我需要用title attibute來索引它。 –

回答

0

最後我發現這個solr的問題。

正在使用solr 6.6 所以我必須按照本教程中的鏈接http://makble.com/how-to-index-mysql-data-in-solr將託管架構重命名爲架構。我還做了一次地理城市的測試。默認情況下,它將託管模式作爲主架構,它使用了我的舊測試模式字段。它沒有獲取schema.xml。

因此,解決辦法是需要定義schema.xml中

<schemaFactory class="ClassicIndexSchemaFactory"/> 

參考鏈接:Data-config.xml and mysql - I can load only "id" column

或重命名託管模式,以SCHEMA.XML或刪除管理型模式