solr elasticsearch - 相关

solr

知识点:
    solr 对 lucene 的封装
    创建Core(表)
    中文分词
    设置字段
    创建索引
    分页查询
    高亮显示
    更新删除索引

命令:
    /bin/...
    solr.cmd start
    solr.cmd create -c me2java  创建core(表)
    solr.cmd delete -c new_core 删除core
    solr.cmd stop -all
    http://127.0.0.1:8983/solr/#/
         
参考:
    https://how2j.cn/k/search-engine/search-engine-start-server/1678.html
 

elasticsearch

知识点:
    elasticsearch:
    C:\Users\X7TI\Downloads\elasticsearch-6.2.2\bin\elasticsearch.bat
    http://127.0.0.1:9200/
    
    kibana:
    C:\Users\X7TI\Downloads\kibana-6.2.2-windows-x86_64\bin\kibana.bat
    http://localhost:5601/app/kibana#/dev_tools/console?_g=()
    
    安装中文分词器
    C:\Users\X7TI\Downloads\elasticsearch-6.2.2\bin\elasticsearch-plugin install file:\\\\C:\Users\X7TI\Downloads\elasticsearch-6.2.2\elasticsearch-analysis-ik-6.2.2.zip
    重启es
    GET _analyze
    {
      "analyzer":"ik_max_word",
      "text":"护眼带光源"
    }

    curl批量导入数据:
    cmd中:
    cd C:\Users\X7TI\Downloads\curl
    curl -H "Content-Type: application/json" -XPOST "localhost:9200/how2java/product/_bulk?refresh" --data-binary "@products.json"
    
   
命令:
    GET /_cat/health?v
    PUT 表示增加
    GET 表示获取
    DELETE 表示删除
    POST 表示更新
    
    创建索引: PUT /how2java?pretty
    查询索引: GET /_cat/indices?v
    删除索引: DELETE /how2java?pretty
    
    1. 增加文档: 
    PUT /how2java/product/1?pretty
    {
      "name": "蜡烛"
    }
    2. 获取文档: GET /how2java/product/1?pretty
    3. 修改文档:
    PUT本来用来做增加的,但是当输入的id已经存在的时候,就自动变成修改功能了
    PUT /how2java/product/1?pretty
    {
      "name": "红色蜡烛"
    }
    POST /how2java/product/1/_update?pretty
    {
      "doc": { "name": "蓝色蜡烛" }
    }   
    4. 删除文档:
    DELETE /how2java/product/1?pretty
    
    批量导入两条数据:
    POST _bulk
    {"index":{"_index":"how2java","_type":"product","_id":10001}}
    {"code":"540785126782","price":398,"name":"房屋卫士自流平美缝剂瓷砖地砖专用双组份真瓷胶防水填缝剂镏金色","place":"上海","category":"品质建材"}
    {"index":{"_index":"how2java","_type":"product","_id":10002}}
    {"code":"24727352473","price":21.799999237060547,"name":"艾瑞泽手工大号小号调温热熔胶枪玻璃胶枪硅胶条热溶胶棒20W-100W","place":"山东青岛","category":"品质建材"}
    {"index":{"_index":"how2java","_type":"product","_id":10003}}
    
    1.查询所有
     GET /how2java/_search
     {
         "query": { "match_all": {} }
     }
    2.id倒排序
    GET /how2java/_search
    {
      "query": { "match_all": {} },
      "sort": [
        { "_id": "desc" }
      ]
    }
    3.返回部分字段
    GET /how2java/_search
    {
      "query": { "match_all": {} },
      "_source": ["name""price"]
    }
    4.条件查询
    GET /how2java/_search
    {
      "query": { "match": { "name": "时尚连衣裙" } }
    }
    5.分页查询
    GET /how2java/_search
    {
      "query": { "match_all": {} },
      "from": 1,
      "size": 3,
      "sort": { "_id": { "order": "desc" } }
    }
    6.聚合查询 
    select count(*),place from product group by place limit 0,3  
    GET /how2java/_search
    {
      "size": 0,
      "aggs": {
        "group_by_place": {
          "terms": {
            "field": "place.keyword",
            "size": 3
          }
        }
      }
    }


参考:
    https://how2j.cn/k/search-engine/search-engine-java-api-index/1700.html

 

 
 

posted @ 2021-04-28 21:20  Alice的小屋  阅读(58)  评论(0编辑  收藏  举报