es使用简单语法案例
#新增索引
PUT trade_bid_price_reduction_sku_pool_t1
{
"mappings": {
"properties": {
"business_suggest_price": {
"type": "long",
"index": false
},
"name": {
"type": "text",
"analyzer": "standard",
"index": true
}
}
}
}
#查询索引
GET trade_bid_price_reduction_sku_pool_t1
#删除索引
DELETE trade_bid_price_reduction_sku_pool_t1
#索引增加字段(不能修改旧字段)
PUT trade_bid_price_reduction_sku_pool_t1/_mapping
{
"properties": {
"cityCode": {
"type": "long"
}
}
}
#-------------------------------------------------------------------#
#插入数据
POST /trade_bid_price_reduction_sku_pool_t1/_doc
{
"business_suggest_price":100,
"name":"test 4",
"cityCode":20
}
#查询数据
GET /trade_bid_price_reduction_sku_pool_t1/_doc/1
#删除数据
DELETE /trade_bid_price_reduction_sku_pool_t1/_doc/1
#修改文档(全量修改)
PUT /trade_bid_price_reduction_sku_pool_t1/_doc/1
{
"business_suggest_price":100,
"name":"test 1"
}
#修改文档(局部修改)
POST /trade_bid_price_reduction_sku_pool_t1/_update/1
{
"doc": {
"name": "test2"
}
}
#全文检索(查询 type = text index = true的数据)
GET /trade_bid_price_reduction_sku_pool_t1/_search
{
"query":{
"match_all": {}
}
}
GET /trade_bid_price_reduction_sku_pool_t1/_search
{
"query":{
"match": {
"name":"test"
}
}
}
GET /trade_bid_price_reduction_sku_pool_t1/_search
{
"query":{
"multi_match": {
"name":"test"
}
}
}
#精确匹配(插叙 其他类型 index = true的数据)
GET /trade_bid_price_reduction_sku_pool_t1/_search
{
"query":{
"term": {
"cityCode":{
"value":"20"
}
}
}
}
GET /trade_bid_price_reduction_sku_pool_t1/_search
{
"query":{
"range": {
"cityCode":{
"gte":"10",
"lte":20
}
}
}
}