#查询所有索引 GET /_cat/indices
GET /_cat/indices?v
#查询索引信息
GET /test1
#删除索引 DELETE /index_name
DELETE /test1
#创建索引
PUT /test1
#创建索引指定分片
PUT /test2
{
"settings": {
"number_of_shards": 1
, "number_of_replicas": 0
}
}
#查询索引映射信息
GET /test1/_mapping
#创建索引指定映射
PUT /test3
{
"mappings": {
"properties": {
"name":{
"type": "text"
},
"age":{
"type": "integer"
}
}
}
}
#基于id的文档crud
#文档添加
POST /test1/_doc/2
{
"name":"qzl",
"age":12
}
#文档查询
GET /test1/_doc/2
#文档删除
DELETE /test1/_doc/1
#文档更新,先删除原来的,再添加
PUT /test1/_doc/1
{
"age":12
}
#文档更新,指定字段进行更新
POST /test1/_doc/2/_update
{
"doc":{
"age":123
}
}
#文档的批量操作
POST /test1/_doc/_bulk
{"index":{"_id":3}}
{"name":"eoi","age":23}
{"index":{"_id":4}}
{"name":"eoi","age":23}
{"update":{"_id":3}}
{"doc":{"age":58}}
{"delete":{"_id":3}}
#查询所有
GET /product/_search
{
"query":{
"match_all":{}
}
}
#字段查询 text是基于es标准的分词器:一个汉字或一个单词
# keyword是全部相同
GET /product/_search
{
"query": {
"term": {
"description": {
"value": "好喝的"
}
}
}
}
#范围查询
GET /product/_search
{
"query": {
"range": {
"age": {
"gte": 10,
"lte": 20
}
}
}
}
#前缀查询
GET /product/_search
{
"query": {
"prefix": {
"description": {
"value": "好喝的"
}
}
}
}
#通配符查询
GET /product/_search
{
"query": {
"wildcard": {
"name": {
"value": "蒙*"
}
}
},
"highlight": {
"fields": {
"*":{}
},
"pre_tags": {}
, "post_tags": {}
}
}
#ids 查询符合一组条件的id
GET /product/_search
{
"query": {
"ids": {
"values": [1,2]
}
}
}
#模糊查询
GET /product/_search
{
"query": {
"fuzzy": {
"FIELD": {}
}
}
}
GET /product/_search
{
"query": {
"multi_match": {
query": "",
"fields": []
},
"query_string": {
"default_field": "FIELD",
"query": "this AND that OR thus"
},
}