当前位置:   article > 正文

es添加索引命令行和浏览器添加索引--图文详解_网页添加索引脚本

网页添加索引脚本

一、添加索引

创建索引

curl -X PUT "localhost:9200/my-index-00001?pretty"

获取索引

curl -X GET "localhost:9200/my-index-000001?pretty"

获取全部的索引

curl -X GET "http://localhost:9200/_cat/indices?v"

获取索引映射 

curl -X GET "localhost:9200/my-index-000001/_mapping?pretty"
删除索引

 

curl -X DELETE "localhost:9200/my-index-000001?pretty"

添加映射:

 

浏览器里执行

  1. PUT /my-index-000001/_mapping
  2. {
  3. "properties": {
  4. "id": {
  5. "type": "text",
  6. "fields": {
  7. "keyword": {
  8. "type": "keyword",
  9. "ignore_above": 256
  10. }
  11. }
  12. }
  13. }
  14. }

 命令行执行

curl -XPUT "http://localhost:9200/my-index-000001/_mapping" -H 'Content-Type: application/json' -d'{  "properties": {     "id": {          "type": "text",          "fields": {            "keyword": {              "type": "keyword",              "ignore_above": 256            }          }        }  }}'

 

重启客户端(这里用的是canal客户端,同步的mysql数据库)

 导入数据

curl -X POST  http://127.0.0.1:8081/etl/es7/mytest_user.yml

 这是我的安装目录:

配置:      /www/canal/adapter/conf/es7/mytest_user.yml

  1. dataSourceKey: defaultDS
  2. destination: example
  3. groupId: g1
  4. esMapping:
  5. _index: my-index-000001
  6. _id: _id
  7. # upsert: true
  8. # pk: id
  9. sql: "select a.id as _id,a.id from t_data_order202306 a"
  10. # objFields:
  11. # _labels: array:;
  12. etlCondition: "where a.id>={}"
  13. commitBatch: 3000

查询数据

 浏览器查询:

  1. GET /my-index-000001/_search
  2. {
  3. "query": {
  4. "match": {
  5. "id": "0000391d-7907-4491-907f-9ebe9d71ab3f"
  6. }
  7. }
  8. }

命令行查询:

curl -XGET "http://localhost:9200/my-index-000001/_search" -H 'Content-Type: application/json' -d'{  "query": {    "match": {      "id": "0000391d-7907-4491-907f-9ebe9d71ab3f"    }  }}'

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/article/detail/46719
推荐阅读
相关标签
  

闽ICP备14008679号