學習solr之前,我想對于初學solr的小夥伴們來說, solr的core概念是最令人頭疼的,到底該怎麼了解solr中的core呢?以下是我從solr的官方文檔中摘下來的一段文字說明:
in solr, the term core is used to refer to a single index and associated transaction log and configuration files (including schema.xml and solrconfig.xml, among others). your solr installation can have multiple cores if needed, which allows you to index data with different structures in the same server, and maintain more control over how your data is presented to different audiences.
in older versions of solr, cores had to be defined in solr.xml in order for solr to know about them. now, however, solr supports automatic discovery of cores and they no longer need to be explicitly defined. instead, core-specific properties (such as the directories to use for the indexes or configuration files, the core name, and other options) are defined in a core.properties file. any core.properties file in any directory of your solr installation (or in a directory under where solr_home is defined) will be found by solr and the defined properties will be used for the core named in the file.
我大緻翻譯下:
在solr中,core術語是用來指代一個單獨的索引、關聯的事務日志以及一些配置檔案(包括schema.xml和solrconfig.xml等等),如果你需要的話,在安裝solr的時候你可以建立多個core,多core模式允許你在同一台伺服器上使用不同的結構來索引你的資料以及在如何把索引資料展現給不同的使用者方面提供了更多的控制。
在老版本solr中,core必須按順序定義在solr.xml配置檔案中,這樣solr才能發現它們,不過現在solr支援自動發現core,core不再需要顯式明确的在solr.xml中定義,替而代之的是,使用core.properties屬性檔案來指定一些core屬性,如:索引目錄,配置檔案,core名稱以及其他可選項。solr會自動在solr安裝目錄下發現core.properties檔案(或者是solr_home目錄下),core.properties配置檔案中定義的參數是用來建立core的。
下面來具體說說core.properties的配置:
name: core的名稱,必填參數
config: 用于指定solrconfig.xml配置檔案的檔案名,預設值是solrconfig.xml
datadir: 指定用于存放lucene索引和log日志檔案的目錄路徑,該路徑是相對于core根目錄(在單core模式下,就直接是相對于solr_home了),預設值是目前core目錄下的data
ulogdir:用來配置指定事務日志檔案路徑的,預設值是目前core目錄下的data目錄下的tlog
schema: 即用來配置你的schema.xml配置檔案的檔案名的,schema.xml配置檔案必須存放在目前core目錄下的conf目錄下
shard:用來設定目前core的分片id,可選參數
collection:用來配置目前core屬于哪個solrclound collection,這裡配置的是該solrclound collection的name值,可選參數
loadonstartup:表示是否在solr啟動部署的時候就加載core并為目前core建立一個新的indexsearcher執行個體
transient:用來設定當solr的transient-cachesize閥值達到限制值的時候,是否自動解除安裝目前core.
下面是一個簡單的core.properties配置示例:

solr在啟動部署的時候,首先會加載core.properties配置檔案,通過core.properties配置來自動發現core,然後根據裡面配置的config和schema來加載solrconfig.xml和schema.xml這兩個核心配置檔案.注意core.properties隻是一些core名稱、核心配置檔案,data資料目錄等等這些參數的定義,加載core.properties配置檔案時,core并沒有開始建立。solrconfig.xml才是關鍵,裡面涉及到solr依賴的lucene版本号,solr依賴的擴充jar包加載位址、lucene索引建立相關參數(比如directoryfactory),過濾器緩存,查詢結果集緩存,document緩存等等配置。有關solrconfig.xml配置檔案的講解留到下一篇再詳細說明,今天就到這兒了,晚安,各位!
如果你還有什麼問題請加我Q-q:7-3-6-0-3-1-3-0-5,
或者加裙
一起交流學習!
轉載:http://iamyida.iteye.com/blog/2211222