1. 程式人生 > >Solr4.x(4.7.0)中新增Solr例項(Core)

Solr4.x(4.7.0)中新增Solr例項(Core)

在下載的solr的解壓包的事例中,預設只有一個Core(collection1),如果想新增自己的Core,比如我想新增一個Core(item),可以使用如下的步驟:

1. 在Solr的Home目錄的solr目錄中建立資料夾item(在C:\solr-tomcat\solr中建立item).

2.在新建立的item目錄中建立兩個資料夾data和conf。

3.將collection1中的conf目錄下的所有檔案copy到新建立的conf目錄下。

4.使用如下的url增加item Core。

http://localhost:9898/solr/admin/cores?action=CREATE&name=item&instanceDir=item&config=solrconfig.xml&schema=schema.xml&dataDir=data

(9898是Solr啟動的埠,如果Solr是在Tomcat中啟動,則是Tomcat的埠)

如果成功建立,則會顯示類似如下的資訊:

<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">4220</int>
</lst>
<str name="core">item</str>
</response>

如果多次建立,則會顯示類似如下的錯誤資訊:

<strname="msg

">Core with name 'item' already exists.</str>

解決這個錯誤,只需要刪除item目錄下的core.properties檔案然後重新執行如下url即可新增item Core

http://localhost:9898/solr/admin/cores?action=CREATE&name=item&instanceDir=item&config=solrconfig.xml&schema=schema.xml&dataDir=data

5. 經過以上步驟後,item這個Core應該已經建立成功,可通過類似如下的URL檢視

http://localhost:9898/solr/#/~cores/collection1