这个是数据结构
PUT hotel
{
"mappings": {
"hotel_search": {
"properties": {
"hotel_price_storage": {
"type": "join",
"relations": {
"hotel": "price_storage"
}
}
}
}
}
}
这个是数据
PUT hotel/hotel_search/7?refresh
{
"hotelCode": 369,
"hotelName": "新测试",
"brandName": "我是一条测试数据",
"cityId": 310100,
"hotel_price_storage": {
"name": "hotel"
}
}
PUT hotel/hotel_search/8?routing=7&refresh
{
"date": "2019-01-26",
"price": 30,
"inventory": 40,
"hotelCode": 369,
"hotel_price_storage": {
"name": "price_storage",
"parent": "7"
}
}
PUT hotel/hotel_search/9?routing=7&refresh
{
"date": "2019-01-27",
"price": 1,
"inventory": 40,
"hotelCode": 369,
"hotel_price_storage": {
"name": "price_storage",
"parent": "7"
}
}
这个是我的查询dsl
POST hotel/_search
{
"query": {
"has_child": {
"type": "price_storage",
"score_mode": "min",
"inner_hits": {
"sort": [
{
"date": {
"order": "asc"
}
}
]
},
"min_children": 2,
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"field_value_factor": {
"field": "price"
}
}
]
}
}
}
},
"sort": [
{
"_score": {
"order": "asc"
}
}
]
}
现在我要通过查询第一天的价格信息进行排序,
比如我查2019-01-26 至2019-01-29,就按2019-01-26当天的价格排序,
如果我查2019-02-01 至2019-02-03,就按2019-02-01当天的价格排序,
现在应该怎么写查询呢?求指教啊
PUT hotel
{
"mappings": {
"hotel_search": {
"properties": {
"hotel_price_storage": {
"type": "join",
"relations": {
"hotel": "price_storage"
}
}
}
}
}
}
这个是数据
PUT hotel/hotel_search/7?refresh
{
"hotelCode": 369,
"hotelName": "新测试",
"brandName": "我是一条测试数据",
"cityId": 310100,
"hotel_price_storage": {
"name": "hotel"
}
}
PUT hotel/hotel_search/8?routing=7&refresh
{
"date": "2019-01-26",
"price": 30,
"inventory": 40,
"hotelCode": 369,
"hotel_price_storage": {
"name": "price_storage",
"parent": "7"
}
}
PUT hotel/hotel_search/9?routing=7&refresh
{
"date": "2019-01-27",
"price": 1,
"inventory": 40,
"hotelCode": 369,
"hotel_price_storage": {
"name": "price_storage",
"parent": "7"
}
}
这个是我的查询dsl
POST hotel/_search
{
"query": {
"has_child": {
"type": "price_storage",
"score_mode": "min",
"inner_hits": {
"sort": [
{
"date": {
"order": "asc"
}
}
]
},
"min_children": 2,
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"field_value_factor": {
"field": "price"
}
}
]
}
}
}
},
"sort": [
{
"_score": {
"order": "asc"
}
}
]
}
现在我要通过查询第一天的价格信息进行排序,
比如我查2019-01-26 至2019-01-29,就按2019-01-26当天的价格排序,
如果我查2019-02-01 至2019-02-03,就按2019-02-01当天的价格排序,
现在应该怎么写查询呢?求指教啊
3 个回复
aa1356889
赞同来自:
forwujinwei
赞同来自:
zcc_vv - 95
赞同来自: