ES教程
1、创建索引 indextest
curl -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/indextest -d '{
"settings" : {
"number_of_shards" : 4,
"number_of_replicas" : 0
},
"mappings" : {
"_doc" : {
"properties" : {
"field1" : { "type" : "text" },
"field2" : { "type" : "text" }
}
}
}
}'
2、查看表结构
http://127.0.0.1:9200/indextest/_mapping
3、添加数据
curl -H "Content-Type: application/json" -XPOST http://127.0.0.1:9200/indextest/_doc -d '{
"field1": "indextest this test field1",
"field2": "indextest this test field2"
}'
4、查询数据
单个索引查询 http://127.0.0.1:9200/indextest/_doc/_search?q=field1:test
多索引联合查询 http://127.0.0.1:9200/indextest*/_search?q=field1*
5、更新数据, Us2DHGsB2841nEVQp6wS为要更新的ID
curl -H "Content-Type: application/json" -XPOST http://127.0.0.1:9200/indextest/_doc/Us2DHGsB2841nEVQp6wS -d '{
"_doc":{
"field1": "this test field1 updata",
"field2": "this test field2 updata"}
}'
6、删除某一条数据 Us2DHGsB2841nEVQp6wS为要删除的ID,如果没有此ID,则会新增
curl -XDELETE -u elastic:changeme http://127.0.0.1:9200/indextest/_doc/Us2DHGsB2841nEVQp6wS
7、删除索引块
curl -XDELETE -u elastic:changeme http://127.0.0.1:9200/indextest
字段类型
核心类型 字符串类型 string,text,keyword
整数类型 integer,long,short,byte
浮点类型 double,float,half_float,scaled_float
逻辑类型 boolean
日期类型 date
范围类型 range
二进制类型 binary
复合类型 数组类型 array
对象类型 object
嵌套类型 nested
地理类型 地理坐标类型 geo_point
地理地图 geo_shape
特殊类型 IP类型 ip
范围类型 completion
令牌计数类型 token_count
附件类型 attachment
抽取类型 percolator