- 1.Installing Solr:
A walkthrough(演示) of the Solr installation process. - 2.Running Solr:
An introduction to running Solr. Includes information on starting up the servers, adding documents, and running queries. - 3.A Quick Overview:
A high-level overview of how Solr works. - 4.A Step Closer:
An introduction to Solr’s home directory and configuration options. 5.Solr Control Script Reference:
a complete reference of all of the commands and options available with the bin/solr script.1.Installing Solr:
需要java1.8及以上(java -version验证一下);
Linux, OS X, and Microsoft Windows平台都可安装;
下载:http://lucene.apache.org/solr/,Linux/Unix/OSX 操作系统下载.tgz file,Microsoft Windows下载.zip
解压到本地(linux):
cd /
tar zxf solr-x.y.z.tgz
(在生产环境安装可能会有不同,方便起见,后面再看)
- 2.Running Solr:
启动:
$ bin/solr start(默认在8983端口启动)
bin\solr.cmd start
查看帮助
solr -help
solr前台运行
solr start -f
在不同的端口启动
solr start -p 8984
停止
solr stop -p 8983(或者bin/solr stop -all)
Ctrl-c(前台启动)
启动solr提供的例子
bin/solr -e techproducts(目前有techproducts, dih, schemaless, and cloud)
查看solr状态
$ bin/solr status
UI界面 http://localhost:8983/solr/
Create a Core
创建一个节点
$ bin/solr create -c <name>
查看帮助
$ bin/solr create -help
Add Documents
solr可以上传的文档类型XML and JSON , CSV , 包含富文本的目录树, 甚至是网络爬虫
solr可以输出的文档格式JSON, PHP, Ruby ,XML,Python,CSV,甚至用户自定义的格式
Add Documents
查询关键字
http://localhost:8983/solr/gettingstarted/select?q=video
指定返回列
http://localhost:8983/solr/gettingstarted/select?q=video&fl=id,name,price
指定查询列
http://localhost:8983/solr/gettingstarted/select?q=name:black
设置查询范围
http://localhost:8983/solr/gettingstarted/select?q=price:[0%20TO%20400]&fl=id,name,price
分组查询 faceting是solr的重要特性
http://localhost:8983/solr/gettingstarted/select?q=price:[0%20TO%20400]&fl=id,name,price&facet=true&facet.field=cat
添加过滤条件(fq fq和q的差别之一是 fq不会高亮)
http://localhost:8983/solr/gettingstarted/select?q=price:0%20TO%20400&fl=id,name,price&facet=true&facet.field=cat&fq=cat:software
- 3.A Quick Overview:
添加搜索能力的4个步骤:
1. Define a schema
2. Deploy Solr.
3. Feed Solr documents for which your users will search.
4. Expose search functionality in your application.
Solr的query是RESTFUL形式的,本质上,query是简单的http请求URL,它的响应是结构化的文档,主要是XML,也可能是JSON,CSV, or some other format.
任何能使用HTTP的平台都能使用solr.
“Sharding”是一种将collection分成多个逻辑上的分片(shards)的技术,为了提高在collection中的文档数量,超过单台服务所能提供的物理上的数量。到来的查询被分发到collection的每个shard上,响应时取合并后的结果。另一个技术是提高collection的Replication Factor(复制因子),允许你用你collection的拷贝来添加服务器,以便处理高并发的查询, load by spreading the requests around to multiple machines,Sharding and Replication不是互斥的,他们一起是Solr称为强大的,可扩展的平台。
相关链接
( Documents, Fields, and Schema Design)
( See Client APIs)
(Searching)
(SolrCloud)
* 4.A Step Closer:
这个模块描述Solr的home目录和其他的配置选项
当solr运行时,solr要访问home目录。home目录包括重要的配置信息,并且存放索引。当solr以standalone模式和SolrCloud模式运行时,home目录结构略有不同
重要的需要知道的配置文件:
solr.xml:为你的solr应用实例指定配置
Per Solr Core(每个solr core中):
core.properties:
solrconfig.xml :
managed-schema (or schema.xml instead):
data/ :The directory containing the low level index files
- 5.Solr Control Script Reference:
solr的脚本:
- Start and Restart
bin/solr start [options]
bin/solr start -help
bin/solr restart [options]
bin/solr restart -help
- Start and Restart
bin/solr start -h localhost -p 8983 -d server -s solr -m 512m
- Setting Java System Properties
bin/solr start -Dsolr.autoSoftCommit.maxTime=3000 - SolrCloud Mode(使用自己的ZK或内嵌的ZK)
bin/solr start -c
bin/solr start -cloud
- Running with Example Configurations
bin/solr start -e
name包括:cloud\techproducts\dih\schemaless
- Stop
bin/solr stop [options]
bin/solr stop -help
bin/solr stop -p 8983
bin/solr stop -all
bin/solr stop -k solrrocks
6. version
$ bin/solr version
7. status
bin/solr status
8. Healthcheck(给出solr cloud模式下collection的健康报告)
bin/solr healthcheck [options]
bin/solr healthcheck -help
9. Collections and Cores(Create)
bin/solr create [options]
bin/solr create -help
10. Configuration Directories and SolrCloud
11. Data-driven Schema and Shared Configurations
12. Delete
13. ZooKeeper Operations