GET _search
{
"query": {
"match_all": {}
}
}
# 默认的分词
GET _analyze
{
"text": "共和国国歌"
}
# ik插件的 ik_smart
GET _analyze
{
"analyzer":"ik_smart",
"text":"中华人民共和国中央人民政府万岁"
}
# ik插件的 ik_max_word 分词
GET _analyze
{
"analyzer":"ik_max_word",
"text":"中华人民共和国中央人民政府万岁"
}
# 删除索引
DELETE school
# 创建索引 number_of_shards 指定分片,number_of_replicas指定副本书
PUT school
{
"settings":{
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings":{
"student":{
"properties":{
"name":{
"type":"text"
},
"address":{
"type":"keyword"
},
"age":{
"type":"integer"
},
"date":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss|| yyy-MM-dd||epoch_millis"
}
}
}
}
}
# 插入数据不指定ID,指定ID为1
PUT /school/student/1
{
"name":"杨旭",
"address":"山东烟台",
"age":23,
"date":"1995-04-12"
}
# 插入数据不指定ID,系统默认设置ID
POST /school/student/
{
"name":"张小花",
"address":"山东烟台",
"age":24,
"date":"1996-07-24"
}
# 查询id为1 的学生信息
GET /school/student/1
GET /school/student/1?_source
# 查询id为1 的学生的都地址
GET /school/student/1?_source=address
# 查询id为1 的学生名字和地址
GET /school/student/1?_source=name,address
# 查询所有数据
GET /school/_search/
{
"query": {
"match_all": {
}
}
}
# SQL 查询
POST /_xpack/sql?format=txt
{
"query":"select * from school where 1=1 "
}
# SQL 查询
POST /_xpack/sql?format=txt
{
"query":"select * from school where 1=1 and age = 23 "
}
最后修改于 2019-12-30 15:46:34
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

