一、添加索引
创建索引
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"
添加映射:
浏览器里执行
PUT /my-index-000001/_mapping
{
"properties": {
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
命令行执行
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
dataSourceKey: defaultDS
destination: example
groupId: g1
esMapping:
_index: my-index-000001
_id: _id
# upsert: true
# pk: id
sql: "select a.id as _id,a.id from t_data_order202306 a"
# objFields:
# _labels: array:;
etlCondition: "where a.id>={}"
commitBatch: 3000
查询数据
浏览器查询:
GET /my-index-000001/_search
{
"query": {
"match": {
"id": "0000391d-7907-4491-907f-9ebe9d71ab3f"
}
}
}
命令行查询:文章来源:https://www.toymoban.com/news/detail-767819.html
curl -XGET "http://localhost:9200/my-index-000001/_search" -H 'Content-Type: application/json' -d'{ "query": { "match": { "id": "0000391d-7907-4491-907f-9ebe9d71ab3f" } }}'
文章来源地址https://www.toymoban.com/news/detail-767819.html
到了这里,关于es添加索引命令行和浏览器添加索引--图文详解的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!