solr start

solr script

  1. solr如何启动:
     bin/solr start
    
  • 需注意新版本的solr需要jdk1.8
  • 或修改SOLR_JAVA_HOME环境变量

启动成功:

    Started Solr server on port 8983 (pid=79131). Happy searching!
  1. 启动一个带有example的实例
        bin/solr -e techproducts
    
  2. 查看solr 运行状态:
      bin/solr status
    
    返回结果:
    Solr process 79392 running on port 8983
    

{
"solr_home":"/opensource/solr- 6.0.1/example/techproducts/solr",
"version":"6.0.1 c7510a0fdd93329ec04c853c8557f4a3f2309eaf - sarowe - 2016-05-23 19:40:37",
"startTime":"2016-07-18T15:53:57.391Z",
"uptime":"0 days, 0 hours, 0 minutes, 45 seconds",
"memory":"27.8 MB (%5.7) of 490.7 MB"}
```

  1. 创建一个新的core
  bin/solr create -c 
  1. 向一个core中添加文档信息:

    bin/post 支持多种类型的数据格式

  bin/post -c gettingstarted example/exampledocs/*.xml
  /** 需已经创建好gettingstarted core*/
  1. 以solrcloud模式启动
bin/solr start -c  
bin/solr start -cloud
  1. solr stop
bin/solr stop

查看solr界面:

访问 http://localhost:8983/solr/

solr start_第1张图片
solr http 界面

查询结果:

  • 向server 请求

    http://localhost:8983/solr/gettingstarted/select?q=video
    
    solr start_第2张图片
    请求结果
  • 指定返回的字段

http://localhost:8983/solr/gettingstarted/select?q=video&fl=id,name,price

使用fl 可以指定返回的字段名称 e.g fl=id,name,price


solr start_第3张图片
指定返回字段
  • 查询指定字段:
    可以使用 __{field} : {value} __ 查询指定字段
    如果不指定查询字段查询schema中配置的默认字段:
    http://localhost:8983/solr/gettingstarted/select?q=name:black

  • 带查询范围的字段:
    http://localhost:8983/solr/gettingstarted/select?q=price:[0 TO 400]&fl=id,name

  • Faceted browsing
    可以允许用户缩小查询的结果
    作为一个第三方的查询结果 ,需要在查询字符串中添加
    facet=true facet.field=cat
    查询结果:
    http://localhost:8983/solr/gettingstarted/select?q=price:[0 TO 400]&fl=id,price&facet=true&facet.field=cat

    solr start_第4张图片
    Faceted 结果

    查询结果显示了指定的查询返回的结果集,针对cat 字段可能的值和数目.可以添加查询条件

    http://localhost:8983/solr/gettingstarted/select?q=price:0%20TO%20400&fl=id,name,price&facet=true&facet.field=cat&fq=cat:software
    
solr start_第5张图片
with facat param

solr 为电商网站添加搜索能力

  1. 设计schema
    schema 告诉,在电商的场景下可能会是产品名称,描述,价格,制造商,等等。
  2. 部署solr
  3. 向solr提供文档,以便检索。
  4. 向程序提供搜索功能

solr 提供RESTFUL的接口,request是 url,response是结构化的文档,包括json,xml,csv等等
同时在高并发,大数据量的环境下可以使用solrCloud去满足单机性能不足的需求。
e.g:
有两种处理的方式:

  1. Sharding
  2. Replication

solr.home

solr 配置文件结构:

      
          / solr.xml
           core_name1/ 
                core.properties 
           conf/
                solrconfig.xml
                managed-schema
           data/
           core_name2/ 
                core.properties 
                data/

自由转载-非商用-非衍生-保持署名 Creative Commons BY-NC-ND 3.0

你可能感兴趣的:(solr start)