发表时间: 2008年08月01日 星期五,作者: lyhiving
分类: 默认分类
奥运期间,请各站长加强自己网站的信息管理,特别是一些政治敏感的,请赶快屏蔽掉。
以下为8月接到的关键字列表,有两份,里面的内容都需要作出屏蔽。请大家自行下载。
发表时间: 2008年04月01日 星期二,作者: lyhiving
分类: solr
Chinese:
Solr 跟 Lucene的中文資料不容易找,根據我自己經過多次嘗試後安裝成功的經驗在此先記錄下我自己的安裝方法,本來是以為Tomcat 5.5 跟 Tomcat 6.x 會一樣,結果發現有點小改變,但這裡因為我自己用的是Tomcat 5.5跟solr 1.2,所以暫時沒有關於Tomcat 6.x 跟 solr 1.2的詳細安裝方式,如果有人有Tomcat 6.x 跟 solr 1.2的安裝問題再發問吧.
Step 1.
Download a solr release from http://www.apache.org/dyn/closer.cgi/lucene/solr/, and extract it.
先下載 solr 壓縮檔並解壓縮到你的主機內.
Step 2.
Assuming that you extracted your solr to a folder named: apache-solr-1.2.0 (you can name it anyway and store it anywhere you want it.)
假設你的 solr 是解壓縮到 apache-solr-1.2.0 這個資料夾.
Step 3.
Stop Tomcat server.
Copy the apache-solr-1.2.0/dist/apache-solr-versionOfSolr.war to /usr/local/solr.war
(Do not put the solr.war in webapps directory)
停止 Tomcat, 先找這個資料途徑內的war檔: apache-solr-1.2.0/dist/apache-solr-xxx.war
複製這個war檔到/usr/local/ 並更名為 solr.war.
(solr.war 檔放哪都可以,就是不要放在webapps裡)
Copy the apache-solr-xxxx (or apache-solr-1.2.0 whatever the source folder is named)/example/solr directory to /usr/
複製 apache-solr-xxxx(下載後解壓縮的資料夾名稱,在此以apache-solr-xxx代表)/example/solr 這個資料夾到 /usr/
Step 4.
Creat a solr.xml under tomcat/conf/Cataline/localhost/ with the following content:
<Context docBase=”/usr/local/solr.war” debug=”0″ crossContext=”true” >
<Environment name=”solr/home” type=”java.lang.String” value=”/usr/solr” override=”true” />
</Context>
在 tomcat的 conf/Cataline/localhost/ 裡建立一個 solr.xml檔,並在內容寫上
<Context docBase=”/usr/local/solr.war” debug=”0″ crossContext=”true” >
<Environment name=”solr/home” type=”java.lang.String” value=”/usr/solr” override=”true” />
</Context>
docBase 要指定到你的solr.war的位置.
value 要指到你的 /solr/資料夾的位置.
Step 5.
Start Tomcat, and go to http://localhost(or tomcat IP)/solr/admin
If you get the solr admin page as shown on the solr wiki site, you have your solr installed and running.
啟動 Tomcat. 然後去tomcat的ip或 localhost下的 /solr/admin 頁面看看, 如果不是錯誤訊息頁面應該就安裝成功了.
Step 6.
Once you get your solr running, you can start configuring your solrconfig.xml and schema.xml of solr in solr/conf/ directory according to the guide on Solr wiki site. (Note: Don’t forget to restart your tomcat after editing solrconfig.xml or schema.xml)
solr 會跑後當然就是要根據你的需要更改設定啦. 需要設定的檔有 solrconfig.xml 跟 schema.xml兩個檔.
你可以在 /usr/solr/conf 資料夾內找到這兩個檔. 設定方法可以參考 solr wiki的網站,這裡就暫時不討論.
最重要的是要記得每次跟改後要記得重新開啟 tomcat 這樣新的設定才會被套用.
That’s it for today, I will try my best to keep this post up to date, and I will keep posting some related topics about solr.
For more detail about solr please refer to http://wiki.apache.org/solr/SolrTomcat
发表时间: 2008年04月01日 星期二,作者: lyhiving
分类: solr
1. 首先假設我的資料裡fields有:name, subbranch, tel, address 預設的搜尋是name這個欄位, 如果要搜尋的資料剛好就是 name 這個欄位,就不需要指定搜尋欄位名稱.
2. 查詢規則:
如欲查詢特定欄位(非預設欄位),請在查詢詞前加上該欄位名稱加 “:” (不包含”號) 符號,
例如: address:台北台北市中正區重慶南路一段xxx號 tel:23xxxxx1
1. q代表query input
2. version代表solr版本(建議不要變動此變數)
3. start代表顯示結果從哪一筆結果資料開始,預設為0代表第一筆, rows是說要顯示幾筆資料,預設為10筆
(因為有時查詢結果可能有幾百筆,但不需要顯示所有結果,所以預設是從第一筆開始到第十筆)
所以若要顯示第10到30筆就改為:
http: //localhost:8080/solr/select/?indent=on&version=2.2&q=address:台北 台北市中正區重慶南路一段xxx號+tel:23xxxxx1&version=2.2&start=10&rows= 20&indent=on
4. indent代表輸出的xml要不要縮行.預設為開啟 on
5. 另外,要限定輸出結果的內容可用 “fl=” 加上你要的欄位名稱,如以下這個範例:
http: //localhost:8080/solr/select/?indent=on&version=2.2&q=text:總統府+ OR+text:郵局&start=0&rows=10&fl=name,subbranch,tel
在fl=之後加上了name,subbranch,tel
所以結果會如下:
<result name=”response” numFound=”1340″ start=”0″>
<doc>
<str name=”name”>總統府郵局</str>
<str name=”subbranch”>台北15支</str>
<str name=”tel”>23xxxxxx9</str>
</doc>
<doc>
<str name=”name”>總統府</str>
<str name=”subbranch”/>
<str name=”tel”>23xxxxxx1</str>
</doc>
</result>
3. 查詢 name 或 subbranch:直接輸入查詢詞, 如: 7-eleven 忠孝店
送出的內容即為:
name:7-eleven AND subbrahch:忠孝店
4. 若要搜尋聯集結果,請在詞與詞間空格或加上大寫 “OR” (不包含”號).
例如: text:總統府 OR text:郵局
text:總統府 OR 郵局
或
總統府 郵局
或
name:總統府 OR tel:23xxxxxx3
或
name:總統府 tel:23xxxxxx3
5. 若要搜尋交集結果,請在詞與詞間加上大寫 “AND” 或 “+” (不包含”號).
例如: text:總統府 AND text:郵局
或
+text:總統府 +text:郵局
或
name:總統府 AND tel:23xxxxxx3
或
name: ( +總統府 +郵局)
6. 排除查詢
在要排除的詞前加上 “-” (不包含”號) 號
例如: 總統府 -郵局
搜尋結果不會有包含郵局的詞的結果在內
7. Group 搜尋
使用 “()” 來包含一個group
如希望搜尋在店名欄位內同時有 “台北”(不包含”號) 及 “火車站”(不包含”號)
8. 增加權重: 如要搜尋 “中華 加油站”(不包含”號) 但因為回傳太多筆資料內有 “中華”(不包含”號) 或 “加油站”(不包含”號) 的結果,
所以想要把有包含 “加油站”(不包含”號)的資料往前排,可使用 “^”(不包含”號)符號在後面加上愈增加的權重數,
像是 “2″,則可以這樣做:
中華 加油站^2
會同時搜尋含有中華或加油站的結果,並把加油站這個詞加權所以搜尋時會先判斷加油站這一個詞在
搜尋結果中的比重,甚至假設一筆資料內加油站出現過兩次以上的就更加會有優先權.
查詢時在查詢詞後加上 “^” (不包含”號) 再加上權重分數
例如: 總統府 AND “郵局”^2
或
總統府^2 OR 郵局
9. Wildcard 搜尋使用 “*” 符號; 如果輸入 “中國*銀” (不包含”號), 結果會有中國信託商業銀行, 中國輸出入銀行圖書閱覽室, 中國商銀證券
中國及銀之間可夾任何長短字詞.
10. 當然還有一些更深入的用法,這裡只是初級的解說,若有興趣可以看看 lucene 或 solr的 document.