GET _cat/health?v
GET _nodes
GET _cat/indices?v
PUT /test?pretty
DELETE /test?pretty
PUT /ecommerce/_doc/1
{
"product_id":1234,
"product_name": "南极人",
"price":99.9,
"color":"Red",
"tags":["轻松","舒服"]
}
PUT /ecommerce/_doc/2
{
"product_id":5678,
"product_name": "寓美",
"price":199.9,
"color":"White",
"tags":["透气","实惠"]
}
PUT /ecommerce/_doc/3
{
"product_id":23333,
"product_name": "金利来",
"price":1899.9,
"color":"Blue",
"tags":["奢侈","豪华"]
}
PUT /ecommerce/_doc/4
{
"product_id":4444,
"product_name": "南极人上衣",
"price":19.9,
"color":"Yellow",
"tags":["保暖","豪华"]
}
GET /ecommerce/_doc/1
PUT /ecommerce/_doc/1
{
"product_id":1234,
"product_name":"南极人裤子",
"price":99.9,
"color":"Red",
"tags":["保暖","舒服"]
}
POST /ecommerce/_update/1
{
"doc": {
"product_id": 1234
}
}
DELETE /ecommerce/_doc/1
GET _search
{
"query": {
"match_all": {}
},
"timeout": "1ms"
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人"
}
},
"sort": [
{
"price": {
"order": "desc"
}
}
]
}
GET /ecommerce/_search
{
"query": {
"match_all": {}
},
"_source":["product_id","product_name"]
}
GET /ecommerce/_search
{
"query": {"match_all": {}},
"from": 0,
"size": 1
}
# https://www.elastic.co/guide/en/elasticsearch/reference/7.0/query-filter-context.html
GET /ecommerce/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"product_name": "南极人"
}
}
],
"filter": {"range": {
"price": {
"gte": 20,
"lte": 100
}
}}
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人"
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人"
}
},
"highlight": {
"fields": {
"product_name":{}
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人上衣"
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": {
"query": "南极人上衣",
"operator": "and"
}
}
}
}
GET /ecommerce/_search
{
"query": {
"match_phrase": {
"product_name": "南极人上衣"
}
}
}
Set fielddata=true on [tags] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
PUT /ecommerce/_mapping
{
"properties": {
"tags":{
"type": "text",
"fielddata": true
}
}
}
GET /ecommerce/_search
{
"aggs": {
"whatever": {
"terms": {
"field": "tags",
"size": 10
}
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人"
}
},
"aggs": {
"NAME": {
"terms": {
"field": "tags",
"order": {
"avg_price": "asc"
},
"size": 10
},
"aggs": {
"avg_price": {
"avg": {
"field": "price"
}
}
}
}
}
}
GET /ecommerce/_search
{
"aggs": {
"price_range": {
"range": {
"field": "price",
"ranges": [
{"from": 0,
"to": 50
},
{
"from": 50,
"to": 100
},
{
"from": 100
, "to": 150
},
{"from": 150,
"to": 200
}
]
},
"aggs": {
"tags_group": {
"terms": {
"field": "tags",
"size": 10
},
"aggs": {
"avg_price": {
"avg": {
"field": "price"
}
}
}
}
}
}
}
}
GET _cat/health?v
GET _nodes
GET _cat/indices?v
PUT /test?pretty
DELETE /test?pretty
PUT /ecommerce/_doc/1
{
"product_id":1234,
"product_name": "南极人",
"price":99.9,
"color":"Red",
"tags":["轻松","舒服"]
}
PUT /ecommerce/_doc/2
{
"product_id":5678,
"product_name": "寓美",
"price":199.9,
"color":"White",
"tags":["透气","实惠"]
}
PUT /ecommerce/_doc/3
{
"product_id":23333,
"product_name": "金利来",
"price":1899.9,
"color":"Blue",
"tags":["奢侈","豪华"]
}
PUT /ecommerce/_doc/4
{
"product_id":4444,
"product_name": "南极人上衣",
"price":19.9,
"color":"Yellow",
"tags":["保暖","豪华"]
}
GET /ecommerce/_doc/1
PUT /ecommerce/_doc/1
{
"product_id":1234,
"product_name":"南极人裤子",
"price":99.9,
"color":"Red",
"tags":["保暖","舒服"]
}
POST /ecommerce/_update/1
{
"doc": {
"product_id": 1234
}
}
DELETE /ecommerce/_doc/1
GET _search
{
"query": {
"match_all": {}
},
"timeout": "1ms"
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人"
}
},
"sort": [
{
"price": {
"order": "desc"
}
}
]
}
GET /ecommerce/_search
{
"query": {
"match_all": {}
},
"_source":["product_id","product_name"]
}
GET /ecommerce/_search
{
"query": {"match_all": {}},
"from": 0,
"size": 1
}
# https://www.elastic.co/guide/en/elasticsearch/reference/7.0/query-filter-context.html
GET /ecommerce/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"product_name": "南极人"
}
}
],
"filter": {"range": {
"price": {
"gte": 20,
"lte": 100
}
}}
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人"
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人"
}
},
"highlight": {
"fields": {
"product_name":{}
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人上衣"
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": {
"query": "南极人上衣",
"operator": "and"
}
}
}
}
GET /ecommerce/_search
{
"query": {
"match_phrase": {
"product_name": "南极人上衣"
}
}
}
Set fielddata=true on [tags] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
PUT /ecommerce/_mapping
{
"properties": {
"tags":{
"type": "text",
"fielddata": true
}
}
}
GET /ecommerce/_search
{
"aggs": {
"whatever": {
"terms": {
"field": "tags",
"size": 10
}
}
}
}
GET /ecommerce/_search
{
"query": {
"match": {
"product_name": "南极人"
}
},
"aggs": {
"NAME": {
"terms": {
"field": "tags",
"order": {
"avg_price": "asc"
},
"size": 10
},
"aggs": {
"avg_price": {
"avg": {
"field": "price"
}
}
}
}
}
}
GET /ecommerce/_search
{
"aggs": {
"price_range": {
"range": {
"field": "price",
"ranges": [
{"from": 0,
"to": 50
},
{
"from": 50,
"to": 100
},
{
"from": 100
, "to": 150
},
{"from": 150,
"to": 200
}
]
},
"aggs": {
"tags_group": {
"terms": {
"field": "tags",
"size": 10
},
"aggs": {
"avg_price": {
"avg": {
"field": "price"
}
}
}
}
}
}
}
}