solr5.4.1 quick start

solr的重大变化:从5.0开始,solr不再以war包发布(war包可以部署到任何servlet容器中),而是以独立的java服务器程序的形式发布(基于内嵌的jetty),它有启动/停止脚本,还有安装脚本用于在类unix上安装一个solr产品,后续版本不支持部署到其他的servlet容器上(如tomcat)
系统要求: JDK>=1.7,不要使用JVM实验性的-XX参数

官网    https://lucene.apache.org/solr/
quick start:  https://lucene.apache.org/solr/quickstart.html
参考文档    https://cwiki.apache.org/confluence/display/solr/Apache+Solr+Reference+Guide
资源包括api文档     https://lucene.apache.org/solr/resources.html

下载二进制包  solr-5.4.1.tgz
解压缩
tar -xvzf solr-5.4.1.tgz
cd solr-5.4.1/
启动一个叫做cloud的例子  (在example/cloud目录下)
       bin/solr start -e cloud -noprompt
        -e表示要启动一个现有的例子,例子名称是cloud
可以看到solr启动了, 默认就是集群模式(使用两个端口模拟了两个节点,线上业务的集群要使用zookeeper),在浏览器访问  http://localhost:8983/solr

创建索引
bin/post -c gettingstarted docs/
-c gettingstarted表示 collection名字是gettingstarted
docs/表示数据源的目录
索引保存在  example/cloud

搜索一下看有没有数据
在 http://localhost:8983/solr左列,选择 gettingstarted_shard1_replica1 -->query,在q栏输入solr,点击execute query,查询结果会显示到右侧

其他数据源如 Solr XML、Json、CSV,数据库导入使用 Data Import Handler (DIH),还可以编程导入索引
数据库:
        可以先把数据库数据导出到csv,然后再导入到solr
        或者使用DIH

更新索引:操作和创建索引一样,如果某一条数据的ID已经存在了,就会替换掉原来的数据
删除索引
         bin/post -c gettingstarted -d "<delete><id>/home/matthewi/software/solr-5.4.1/docs/solr-morphlines-core/allclasses-noframe.html</id></delete>"
        重新执行上面的搜索可以看到搜索结果的数量少了一条: numFound列

查询
        查询可以使用 REST clients, cURL, wget, Chrome POSTMAN,或者编程实现
        浏览器访问(和上面的图形界面查询一样)
          http://localhost:8983/solr/gettingstarted/select?q=solr&wt=json&indent=true
         http://localhost:8983/solr/gettingstarted/select?q=solr&wt=json&indent=true&start=3&rows=5 &fl=id,date            
                start表示从什么位置开始(索引从0开始),rows表示返回多少条数据,fl表示返回的列(逗号分隔)
         http://localhost:8983/solr/gettingstarted/select?q=stream_size:930&wt=json&indent=true
                 q=stream_size:930限定在stream_size字段搜索930这个字符串

Phrase search
多词检索时,空格会被转换为+

组合查询
     http://localhost:8983/solr/gettingstarted_shard1_replica1/select?q=solr+-api+-util&rows=100&wt=json&indent=true
     http://localhost:8983/solr/gettingstarted_shard1_replica1/select?q=%2Ball+%2Bapi+%2Butil+%2Bcore&wt=json&indent=true
    默认搜索多个词语时,只要有一个词语匹配,就算命中,如果命中越多,排名越靠前
    必须匹配:用+,会转移为%2B
    禁止匹配:用-

Faceting search 分面搜索
     分面是指事物的多维度属性。例如一本书包含主题、作者、年代等分面。而分面搜索是指通过事物的这些属性不断筛选、过滤搜索结果的方法。可以将分面搜索看成搜索和浏览的结合。
    搜索结果统计功能

Spatial 空间搜索
    对地理支持

停止solr
bin/solr stop -all

你可能感兴趣的:(搜索引擎,Solr,jetty)