酒店api
GET /hotel_price/_search
{
"query": {
"match_all": {
}
}
,
"from":1,
"size":10
}
GET _cat/indices?v
GET /hotel_price/_mget
{
"ids":["2_6073_2021-05-24","2_6086_2021-08-05"]
}
# 获取mapping关系
GET /hotel_price/_mapping
GET /hotel_price/_search/
{
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "hotel_name",
"query": "如家"
}
}
],
"filter": {
"range": {
"@timestamp": {
"gte": "now-30d/d",
"lte": "now/d"
}
}
}
}
},
"size": 20
}
GET /hotel_price/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"hotel_name": "汉庭"
}
}
],
"filter": {
"range": {
"@timestamp": {
"gte": "now-30d/d",
"lte": "now/d"
}
}
}
}
},
"size": 10,
"sort": [
{
"_id": {
"order": "desc"
}
}
],
"highlight": {
"fields": {
"hotel_name":{
"pre_tags": ["<emm>"],
"post_tags": ["</emm>"]
}
}
}
}
### 更新图片 旧值更新为新值
POST hotel_price_2021.08.05/_update_by_query
{
"script": {
"source": "ctx._source['coverimage_href']='https://pavo.elongstatic.com/i/Hotel870_470/nw_WANm5wXZHq.jpg';ctx._source['coverimage_href']='http://pavo.elongstatic.com/i/API350_350/42cbd6ae3e1524071e82d3ccc22a9a39.jpg'"
},
"query": {
"bool": {
"must": [
{
"term": {
"mapping_id": {
"value": "1839"
}
}
}, {
"term": {
"prov_code": {
"value": "1"
}
}
}
]
}
}
}
get _template/hotel_price_template
get hotel_price_2021.08.05/_count
{
"query":{
"match_all" : {}
}
}
POST hotel_price_2021.04.14/_update_by_query
{
"script": {
"source": "ctx._source['agreement']='[{\"CompanyId\":\"1fbce0d1-d25a-cbd7-1929-08d763a92d4e\",\"AgreementCode\":\"slys_xy\"}]';ctx._source['has_agreement']='1'"
},
"query":{
"bool" : {
"must" : [
{
"term" : {
"prov_code" : {
"value" : "2"
}
}
}
],
"filter" : [
{
"term" : {
"hotel_id" : {
"value" : "859"
}
}
}
]}
}
}
POST hotel_price_2021.04.14/_update_by_query
{
"script": {
"source": "ctx._source['agreement']='[]';ctx._source['has_agreement']='1'"
},
"query":{
"match": {
"hotel_id":"859"
}
}
}
get hotel_price/_search
{
"query":{
"bool" : {
"must" : [
{
"term" : {
"prov_code" : {
"value" : "1"
}
}
}
],
"filter" : [
{
"term" : {
"hotel_id" : {
"value" : "19188"
}
}
}
]}
},
"collapse": {
"field": "hotel_id"
}
}
get _cat/count?v&pretty
#delete hotel_price_2021.05.08
get hotel_price_2021.06.15/_search
{
"query":{
"match": {
"hotel_name":"重庆格林"
}
}
}
get hotel_price_2021.08.05/_search
{
"query":{
"match": {
"hotel_name":"君庭"
}
}
}
get hotel_price_2021.08.05/_count
{
"query":{
"match_all" : {}
}
}
get hotel_price/_search
{
"query":{
"match": {
"hotel_id":"6583"
}
}
}
get hotel_price/_search
{
"query":{
"match": {
"hotel_id":"6583"
}
}
}
POST /_aliases
{
"actions" : [
{ "remove" : { "index" : "hotel_price_2021.06.15", "alias" : "hotel_price" } }
{ "add" : { "index" : "hotel_price_2021.08.05", "alias" : "hotel_price" } }
]
}
GET hotel_price/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"city_id": {
"value": "34",
"boost": 1
}
}
}
],
"filter": [
{
"match_phrase": {
"hotel_name": {
"query": "君亭",
"slop": 4,
"zero_terms_query": "NONE",
"boost": 1
}
}
},
{
"range": {
"price": {
"from": "0",
"to": "99999",
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
},
{
"range": {
"biz_date": {
"from": "2021-08-09",
"to": "2021-08-11",
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
},
{
"bool": {
"should": [
{
"term": {
"star_rate": {
"value": "0",
"boost": 1
}
}
},
{
"term": {
"star_rate": {
"value": "1",
"boost": 1
}
}
},
{
"term": {
"star_rate": {
"value": "2",
"boost": 1
}
}
},
{
"term": {
"star_rate": {
"value": "3",
"boost": 1
}
}
},
{
"term": {
"star_rate": {
"value": "4",
"boost": 1
}
}
},
{
"term": {
"star_rate": {
"value": "5",
"boost": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
{
"bool": {
"adjust_pure_negative": true,
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
}
电商搜索
GET /goods/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"title": {
"query": "手机",
"operator": "and"
}
}
}
],
"filter": [
{
"nested": {
"path": "attrs",
"query": {
"bool": {
"must": [
{
"term": {
"attrs.attrId": {
"value": "9"
}
}
},
{
"terms": {
"attrs.attrValue": ["5","6","7"]
}
}
]
}
}
}
},
{
"nested": {
"path": "attrs",
"query": {
"bool": {
"must": [
{
"term": {
"attrs.attrId": {
"value": "4"
}
}
},
{
"terms": {
"attrs.attrValue": ["8G", "12G"]
}
}
]
}
}
}
},
{
"terms": {
"brandId": [1,2,3]
}
},
{
"terms": {
"categoryId": [225]
}
},
{
"range": {
"price": {
"gte": 0,
"lte": 10000
}
}
}
]
}
},
"from": 0,
"size": 10,
"highlight": {
"fields": {
"name": {}
},
"pre_tags": "<b style='color:red'>",
"post_tags": "</b>"
},
"sort": [
{
"price": {
"order": "desc"
}
}
],
"aggs": {
"brandIdAgg": {
"terms": {
"field": "brandId"
},
"aggs": {
"brandNameAgg": {
"terms": {
"field": "brandName"
}
}
}
},
"categoryIdAgg": {
"terms": {
"field": "categoryId"
},
"aggs": {
"categoryNameAgg": {
"terms": {
"field": "categoryName"
}
}
}
}
}
}