elasticsearch6.x

搭建:

见: https://blog.csdn.net/qq_50227688/article/details/115379121

kibana下载: https://artifacts.elastic.co/downloads/kibana/kibana-7.4.0-linux-x86_64.tar.gz

 

kibana使用: "ElasticSearch6.x版本快速入门上手教学讲解视频"

https://www.bilibili.com/video/BV1QD4y1V7R7/?p=2&spm_id_from=pageDriver&vd_source=b879d4ff10c4ff63bbd44d7f0839ffa2   (dev tools基础查询)

 

https://www.bilibili.com/video/BV1QD4y1V7R7/?p=3&spm_id_from=pageDriver&vd_source=b879d4ff10c4ff63bbd44d7f0839ffa2  (springboot 操作es)

 

其他记录:

1.查看集群是否正常:  http://ip:9200/_cat/health?v

2.启动先切换用户再执行 ./bin/elasticsearch -d

3.kibana启动: nohup ./kibana --allow-root (bin下)  通过ps -ef | grep node 查看进程

4.kibana访问地址 http://ip:5601

 

springboot + es7 参见 :https://www.jianshu.com/p/ec6e57ad1cde/

 

kibana操作es:

0.查看xxx下type的结构: GET /xxx/_mapping/type

1.添加表结构put

2.添加

  2.1 添加1条, put /xxx/xxx/id, post /xxx/xxx (post会随机生成id)

  2.2 添加多条 put /xxx/xxx/_bulk;  post /xxx/xxx/_bulk (其中post_bulk可以添加删除修改同时进行)

3.删除del, 可以删全部,可以按id删

4.修改post和put

  4.1 POST /xxx/xxx/id/_update 更新1条

  4.2 见.2.2

5.查询get, 可以查一个/xxx/xxx/id;  可以查多个/xxx/xxx/_search

  {

    "query": {  

      "match_all": {} // 查全部

      "term": { "orientation": { "value": "东南" } // 按分词在orientation中查询, 只有text才会分词,其他的都是"等于"

      "range": { "id": { "gte": 5, "lte": 8 } } // 范围查询

      "prefix": { "houseType": { "value": "两" } } // 相当于like "两%"

      "wildcard": { "orientation": { "value": "东*" } } // 模糊查询,注意所查字段不能分词, 相当于like

      "ids": { "values": ["5","8"] } // id范围

      "bool":{"must":[{"range":{"id":{"gte":5,"lte":8}}},{"wildcard":{"renovation":{"value":"精*"}}}],"must_not":[{"wildcard":{"ownerShip":{"value":"comm?"}}}]} // bool查询must=and, mustnot=not, should=or

      "highlight":{"pre_tags":["<span style='color:red'>"],"post_tags":["</span>"],"require_field_match":false,"fields":{"*":{}}} // 高亮, require_field_match默认是true(true表示只高亮查询的字段, false 表示只要高亮所有字段中匹配到的)

      "multi_match": { "query": "你好", "fields": ["info","details"] } // 多字段查询(指定字段中只要有1个能查询到内容, 就会显示出来!) 可以通过should实现.

    },

    "_source": ["houseType", "area"], // 查字段

    "sort": [ { "id": { "order": "desc" } } ], // 排序

    "from": 1, "size": 3, // 分页

  }

posted @ 2023-03-13 17:55  trump2  阅读(40)  评论(0)    收藏  举报