zoukankan      html  css  js  c++  java
  • java应用之solr入门篇

     

    前言

        solr是apache项目的一款全文搜索应用.

        官方文档http://lucene.apache.org/solr/guide/6_6/

    入门流程

        1.安装   --->  2.启动  --->  3.创建核心  ---> 4.添加文档   ---> 5.url接口查询

    1.安装

       下载solr-6.6.0.tgz包,解压任意目录

    2.启动

    /opt/solr-6.6.0/bin
    ./solr start  -force  #root用户需要加force

    3.创建核心

    #创建索引数据文件存放地方。

    ./solr create -c ttt -force  #ttt为核心名称, post和查询时用得到
    

    4.添加文档(POST)

    bin/post -c ttt  example/exampledocs/*.xml #默认用的官方例子
    

    5.url接口查询

    a.curl http://localhost:8983/solr/ttt/select?q=video
    #q为基本查询,固定值不变video是查询的值。q查询是全文查询,可以跟正则符号.
    b.http://localhost:8983/solr/ttt/select?q=video&fl=id,name,price
    #fl固定值,结果返回id,name,price字段
    c.http://localhost:8983/solr/ttt/select?q=name:black
    #还是模糊查询,实验了下name:black没啥特殊含义,是一个整体字符串
    d.http://localhost:8983/solr/ttt/select?q=price:0%20TO%20400&fl=id,name,price
    #price:0 To 400 范围查询
    e.http://localhost:8983/solr/ttt/select?q=price:0%20TO%20400&fl=id,name,price&facet=true&facet.field=cat
    #facet固定值,聚合查询,相当于sql的group by 或 count
    f.http://192.168.0.110:8983/solr/ttt/select?q=price:0%20TO%20400&fl=id,name,price&wt=json
    #wt返回json格式

    更多技巧

    1.用管理端查询

    2.一位博主整理的Solr -- 查询语法/参数

    http://blog.csdn.net/zhufenglonglove/article/details/51518846

      

  • 相关阅读:
    [洛谷P3360]偷天换日
    [BZOJ3195]奇怪的道路
    [BAOJ3631]松鼠的新家
    [BZOJ4899]记忆的轮廓
    [BZOJ3940]Censoring
    P3303 [SDOI2013]淘金
    2019.8.5 NOIP模拟测试13 反思总结【已更新完毕】
    2019.8.3 NOIP模拟测试12 反思总结【P3938 斐波那契,P3939 数颜色,P3940 分组】
    2019.8.1 NOIP模拟测试11 反思总结
    洛谷P2178 [NOI2015]品酒大会
  • 原文地址:https://www.cnblogs.com/whf191/p/7469452.html
Copyright © 2011-2022 走看看