Apache solr 多站設定 multi core setup

在 solr 的詞彙裏面, mulit site 的意思是指一個實體 solr 對應多個網站
和 apache virtual host 類似,
所以你可以同一部機器的一個 solr 放置數個站, 方便管理

而 solr 自帶的 example 資料夾本身已經有一個 multi site 的範例
而要認識 mutli core 的設定, 便先要了解 solr 的預設檔案結構:

start.jar
solr/
--conf/
----schema.xml
----solrconfig.xml

這邊只列出重要的檔案, 其中的 schema.xml 和 solrconfig.xml 都應該要換成 Drupal 自帶的
這是單站的設定, 而多站的設定:
start.jar
solr/
solr.xml
--core0/
----conf/
------schema.xml
------solrconfig.xml
--core1/
----conf/
------schema.xml
------solrconfig.xml

多出了一個 solr.xml 和個資料夾, core0 和 core1

solr.xml 內定義了:

<cores adminPath="/admin/cores">
  <core name="core0" instanceDir="core0" />
  <core name="core1" instanceDir="core1" />
</cores>

對應建立兩個資料夾, 和對應的兩個資料夾名稱
再將 conf 複製便完成了
打開 jetty 之後, 你可以到 /solr/core0/admin, /solr/core1/admin 確認成功設定
而 Drupal 內的 solr path 也需要對應輸入新的 subfix

順帶一提, core0 core1 的命名是不理想的,
應該使用例如 blog, uat, live 之類更加清晰的命名
core0 core1 的命名只是為了簡單解說而已

什麼是 apache solr, 安裝

AttachmentSize
Image icon solr-connection-error.png9.41 KB
Image icon tomcat.png21.11 KB
Image icon tomcat-solr-command-line.png21.29 KB

Apache solr 是一個搜尋器
當網站的流量, 用戶, 內容日益增加的時候
Drupal 內建的 search 很快便會變得很慢
而 apache solr 便是其中的解決方案了

Solr 本身是一個 Java 的程式,
所以安裝的時候會和一般的不一樣
但它 search 的能力是非常強
支持全文搜索, 速度快, 支持單線程多站搜索等等
它還可以加其他的插件
支持更多功能, 例如 faceted search 等等

Faceted search 是指用戶可以根據預定的參數,
再過濾搜尋結果.
例如使用分類, 日期, 作者, 地點或任何一個 field 的值都可以是過濾的參數
這些參數稱為 criteria facets.
有了這些參數, 你便可以根據你的求進行更精確的搜尋了

假如你是使用 windows,
你可以很方便的使用 xampp 的 tomcat server
快速建立一個測試的 solr:

PHP side:

  1. 下載 Apache Solr Search Integration module
  2. 下載 Apache solr 1.4 r22, 解壓到 apachesolr module 之下 eg. /sites/all/modules/apachesolr/SolrPhpClient
  3. 啟用模組的話, 你可以看到成功安裝 r22 的訊息(和連接 solr 錯誤的訊息)

Java side:

  1. 安裝 Java JDK
  2. 下載 Solr 1.4, 解壓到你的 webroot 之外, 例如 /xampp/
  3. Solr 本身帶有一個 example 可用作測試, 備份 apache-solr-1.4.1/example/solr/conf/schema.xml 和 solrconfig.xml
  4. 將 Drupal solr module 的schema.xml 和 solrconfig.xml 複製至此
  5. 啟用命令行, 到 /xampp/apache-solr-1.4.1/example, 執行 java -jar start.jar
  6. http://localhost:8983/solr/admin/ 確認安裝成功!

執行 java -jar start.jar

Views3 的 templates 選項

AttachmentSize
Image icon views3-list.png9.22 KB
Image icon views3-edit.png17.05 KB
Image icon views-edit-advanced.png22.45 KB
Image icon views3-templates.png27.72 KB

Views 3.x 的介面雖然和 views 2.x 有點相似 但便使用了更多的 DHTML, AJAX 技術 之前有網友說找不到 views 3.x templates suggestion 的選項 我截了些圖給大家參考:

Views List

Views Edit

Views Edit Advanced

Views Templates Suggestions

dependency injection, symfony2 code get into drupal 8.x core

Readings:
PHP 5.3 和 5.4 的 dependency injection 的概念, 是進階的物件導向概念
情況慢慢和 java 一樣, 變得複雜, 多了很多 class, 所以還是及早吸收這些概念比較好.
http://css.dzone.com/articles/php-5354-best-practices

另, Drupal 使用 symfony2 的 httpFoundation 作為 D8.x 的一部份, 翻譯一小段:

我們需要使用 HTTP 製式內全部的功能. 而這對 D8 傳送接收 web service 特別重要, 雖然我們現在主要重中在接收的部份. 另外, 我們也想避免使用很多的全局變數, 因為這會大大增加測試, 除錯, 偽裝(mocking) 的難度, 甚至根本不可能完成.

要完成一個完善的庫需要很多的時間, 我們不想要花掉這樣的時間

http://drupal.org/node/1178246

Drush 5.x-dev 支持視窗系統 support Windows system!

http://drupal.org/project/drush

下載點: http://drush.ws/resources
下載完成直接雙擊安裝
安裝完成便可以雙擊桌面圖示, cd 到你的 Drupal root, 開始使用 Drush

還有, Drupal 已經轉用 git 作為版本椌制系統
Windows 下你可以使用 msysgit http://code.google.com/p/msysgit/
它帶有一個 msysgit shell, 可以使用 linux 命令, Drush 命令

再加上 gvimsnipMate, 成就了我終極的, 跨系統的開發工具組

Pages

Google