es 记录
来源:互联网 发布:linux怎么进入编辑 编辑:程序博客网 时间:2024/05/15 04:55
curl -XPUT 'http://10.0.0.176:9200/xiu'
结果 {"acknowledged":true}You have new mail in /var/spool/mail/root
curl -XPOST 'http://10.0.0.176:9200/xiu1'
2,创建索引curl -XPUT 'http://10.0.0.176:9200/xiu1/onsale'
RESTful接口URL的格式:http://localhost:9200/<index>/<type>/[<id>]
其中index、type是必须提供的。
id是可选的,不提供es会自动生成。
3,查看mapping
curl -XGET "http://10.0.0.176:9200/xiu1/_mapping?pretty"
4,创建索引product
curl -XPOST "http://10.0.0.176:9200/xiu1/product/_mapping?pretty" -d '
{
"product": {
"properties": {
"title": {
"type": "string",
"store": "yes"
},
"description": {
"type": "string",
"index": "not_analyzed"
},
"price": {
"type": "double"
},
"onSale": {
"type": "boolean"
},
"type": {
"type": "integer"
},
"createDate": {
"type": "date"
}
}
}
}'
5,新增mapping 字段
curl -XPOST "http://10.0.0.176:9200/xiu1/product/_mapping?pretty" -d '{
"product": {
"properties": {
"amount":{
"type":"integer"
}
}
}
}’
6,修改mapping 字段类型
curl -XPOST "http://10.0.0.176:9200/xiu1/product/_mapping?pretty" -d '{
"product": {
"properties": {
"onSale":{
"type":"string"
}
}
}
}',
7,添加数据
curl -XPOST http://10.0.0.176:9200/xiu1/product/ -d '{"description":"elasticsearch添加索引数据"}'curl -XPOST http://10.0.0.176:9200/xiu1/product/ -d '{"amount":20000,"description":"elasticsearch添加索引数据","title":"中华人民","type":100}'
8,索引查询 格式化
curl -XGET 'http://10.0.0.176:9200/xiu1/product/AV1VlZNJUuvIr5lrbiVh/?pretty'9,查询索引 返回指定字段
curl -XGET 'http://10.0.0.176:9200/xiu1/product/AV1VlthGUuvIr5lrbiVi/?_source=amount,title&pretty'
10,查看某个索引所有数据
curl -XGET 'http://10.0.0.176:9200/xiu1/product/_search?pretty'
11,更新索引
curl -XPOST 'http://10.0.0.176:9200/xiu1/product/AV1VlthGUuvIr5lrbiVi/_update' -d '{"doc":{"title":"中华共和国"}}'
ES全部更新,使用PUT或者POSTES局部更新,使用POST
12,删除索引
curl -XDELETE 'http://10.0.0.176:9200/xiu1/product/AV1VlthGUuvIr5lrbiVi'
13,添加ik分词
在elasticsearch-5.4.0/plugins下添加文件夹 elasticsearch-analysis-ik-5.4.0
14,创建索引 curl -XPUT "http://localhost:9200/testb"
curl -XGET "http://localhost:9200/testb/_analyze?analyzer=ik_max_word" -H 'Content-Type: application/json' -d'
{
"text": "女士牛皮金属装饰芭蕾舞鞋"
}'
结果:{
"tokens": [
{
"token": "女士",
"start_offset": 0,
"end_offset": 2,
"type": "CN_WORD",
"position": 0
},
{
"token": "牛皮",
"start_offset": 2,
"end_offset": 4,
"type": "CN_WORD",
"position": 1
},
{
"token": "牛",
"start_offset": 2,
"end_offset": 3,
"type": "CN_WORD",
"position": 2
},
{
"token": "皮",
"start_offset": 3,
"end_offset": 4,
"type": "CN_WORD",
"position": 3
},
{
"token": "金属",
"start_offset": 4,
"end_offset": 6,
"type": "CN_WORD",
"position": 4
},
{
"token": "装饰",
"start_offset": 6,
"end_offset": 8,
"type": "CN_WORD",
"position": 5
},
{
"token": "饰",
"start_offset": 7,
"end_offset": 8,
"type": "CN_WORD",
"position": 6
},
{
"token": "芭蕾舞鞋",
"start_offset": 8,
"end_offset": 12,
"type": "CN_WORD",
"position": 7
},
{
"token": "芭蕾舞",
"start_offset": 8,
"end_offset": 11,
"type": "CN_WORD",
"position": 8
},
{
"token": "芭蕾",
"start_offset": 8,
"end_offset": 10,
"type": "CN_WORD",
"position": 9
},
{
"token": "芭",
"start_offset": 8,
"end_offset": 9,
"type": "CN_WORD",
"position": 10
},
{
"token": "蕾",
"start_offset": 9,
"end_offset": 10,
"type": "CN_WORD",
"position": 11
},
{
"token": "舞鞋",
"start_offset": 10,
"end_offset": 12,
"type": "CN_WORD",
"position": 12
},
{
"token": "鞋",
"start_offset": 11,
"end_offset": 12,
"type": "CN_WORD",
"position": 13
}
]
}
- ES记录
- es 记录
- ES记录
- es操作记录
- ES错误记录
- ES常用命令记录
- OPENGL ES 常用API记录
- logstash学习记录(es)
- es curator安装使用记录
- ES多条件查询记录(1)
- ES 5.0.2报错记录
- es-hadoop-hive 时间格式问题记录
- mapping创建 添加记录到es
- es 构造dsl性能优化点记录
- es
- es
- es
- es
- conn 不为空,但是conn已经关闭(No operations allowed after connection closed)
- 排序(插入排序,希尔排序,归并排序,快速排序)
- Java编程之十进制转二进制算法
- JavaScript入门(三)
- 数据结构与算法2
- es 记录
- Hyperspectral Band Selection by Multitask Sparsity Puisuit
- Interrupt
- PHP之SQL注入
- CodeForces 624C【二分图染色】
- xampp使用指南
- Hadoop浅见
- Java基础知识
- 基线问题