0.啟動solr
bin/solr start -e techprojects
(下面解決權(quán)限問題)


1.理解索引
1.1定位techproducts文內(nèi)核所在文件目錄,分析目錄結(jié)構(gòu)
輸入網(wǎng)址:http://119.29.41.86:8983/solr/#?? (進入solr控制臺)

1.2 定位 techproducts 索引數(shù)據(jù)的文件位置。
/opt/solr-6.3.0/example/techproducts/solr/techproducts/data/index
1.3 下載索引數(shù)據(jù)到本地,熟悉 Solr/Lucene 索引相關(guān)的多文件結(jié)構(gòu)。
在終端找到上述文件位置進行下載。
1.4 使用 Luke 查看索引數(shù)據(jù)。
1.4.1 在本地打開 Luke jar 應(yīng)用窗口。
1.4.2 打開 techproducts 的索引數(shù)據(jù),熟悉 Luke 的 5 個選項卡,結(jié)合已打開的索引數(shù)據(jù),簡述 Luke 能做什么。

1.4.3 在 search 選項卡中,搜索 name:ipod,查看搜索結(jié)果,點擊 explain,了解第一條搜索結(jié)果的 score 得分。

1.5 了解 schema 的作用。
1.5.1 定位 techproducts 的 schema 信息(managed-schema 文件),對照之前的索引情況,解讀其 schema 內(nèi)容。
/opt/solr-6.3.0/example/techproducts/solr/techproducts/conf/
詳情見:http://www.cnblogs.com/langfanyun/p/5829874.html
1.5.2 定位 techproducts 的被索引文檔(原始文檔),對照索引和 schema 情況,分析多個原始文檔的內(nèi)容構(gòu)成。
2.掌握 Query 查詢構(gòu)造
2.1 搜索制造商為 Belkin 的 iPod 配件,搜索結(jié)果按價格升序排列,搜索結(jié)果內(nèi)容包含名稱(name)、價格(price)、特征(features),返回 xml 數(shù)據(jù)。
查詢請求:
http://120.24.46.77:8983/solr/techproducts/select?fl=name,price,features&fq=Belkin&indent=on&q=iPod&sort=price asc&wt=xml
查詢結(jié)果(片段及分析):

2.2 搜索流行度為 5 及以上的產(chǎn)品,搜索結(jié)果先按 inStock 降序,再按 price 升序,每頁顯示 5 個結(jié)果分頁,搜索結(jié)果內(nèi)容包括名稱(name)、價格(price)、特征(features),受歡迎程度(popularity),返回 json 數(shù)據(jù)。
查詢請求:
http://120.24.46.77:8983/solr/techproducts/select?fl=name,price,features,popularity&fq=popularity:[5 to 20*]&indent=on&rows=5&sort=inStock desc,price asc&wt=json
查詢結(jié)果(片段及分析):

2.3 搜索價格在 400 以下且有存庫的商品,按受歡迎程度降序排列,搜索結(jié)果內(nèi)容包括名稱(name),價格(price),特征(features)及得分(score),返回 json 數(shù)據(jù)。
查詢請求:http://120.24.46.77:8983/solr/techproducts/select?fl=name,price,features,score&fq=price:[0 to 400],inStock:[0 to *]&indent=on&sort=popularity desc&wt=json
查詢結(jié)果(片段及分析):

2.4 在特征(features)字段中搜索“plays”,對其進行高亮,搜索結(jié)果內(nèi)容采用默認形式,返回 xml 數(shù)據(jù)。
查詢請求:
http://120.24.46.77:8983/solr/techproducts/select?fl=features&fq=features&hl=true&hl.field=plays

未完待續(xù)....