Skip to content

Instantly share code, notes, and snippets.

@yanglikun
Last active July 1, 2017 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanglikun/57657ca517098379a2a1eef50b86c3fe to your computer and use it in GitHub Desktop.
Save yanglikun/57657ca517098379a2a1eef50b86c3fe to your computer and use it in GitHub Desktop.
es-share-baseOperator
#show all index 相当于查看有哪些数据库 show databases
GET /_cat/indices?v
#create index 相当于执行DDL语句create database
PUT /es_demo_index
#create type(mapping) 相当于执行DDL语句create table
PUT /es_demo_index/_mapping/es_demo_order_type
{
"es_demo_order_type": {
"properties": {
"id": {
"type": "long"
},
"pin": {
"type": "string"
},
"created": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
}
}
#show index's types 相当于show tables
GET /es_demo_index/_mapping
#index document 相当于insert记录
PUT /es_demo_index/es_demo_order_type/1
{
"id":1,
"pin":"zhangsan",
"created":"2017-07-01 10:40:22"
}
#query data of type 相当于select
GET /es_demo_index/es_demo_order_type/_search
{
"query": {
"match_all": {}
}
}
#create index、type when indexing
PUT /es_demo_index1/es_demo_order_type1/1
{
"id":1,
"pin":"zhangsan",
"created":"2017-07-01 10:40:22"
}
GET /es_demo_index1/es_demo_order_type1/_search
{
"query": {
"match_all": {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment