如何更改我的查询以仅显示订单簿中的 5 个第一订单?
我的数据是这样的结构。订单是嵌套类型。
Orderbook
|_ Orders
这是我的查询
GET /orderindex/_search
{
"size": 10,
"query": {
"term": { "_type": "orderbook" }
}
}
这就是结果
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 10,
"max_score": 1,
"hits": [
{
"_index": "orderindex",
"_type": "orderbook",
"_id": "1",
"_score": 1,
"_source": {
"id": 1,
"exchange": "Exch1",
"label": "USD/CAD",
"length": 40,
"timestamp": "5/16/2018 4:33:31 AM",
"orders": [
{
"pair1": "USD",
"total": 0.00183244,
"quantity": 61,
"orderbookId": 0,
"price": 0.00003004,
"exchange": "Exch1",
"id": 5063,
"label": "USD/CAD",
"pair2": "CAD",
},
{
"pair1": "USD",
"total": 0.0231154,
"quantity": 770,
"orderbookId": 0,
"price": 0.00003002,
"exchange": "Exch1",
"id": 5064,
"label": "USD/CAD",
"pair2": "CAD",
},
...
..
.
另外,如何通过标签名称查询两个特定的订单簿并仅检索前 2 个订单?
我现在正在发送此查询,但问题是它返回了包括所有订单在内的订单簿,然后在此之后它只返回 2 个加内部命中。我该如何做才能仅返回 2 个内部点击,而不返回查询第一部分中订单簿附带的所有订单
GET /orderindex/_search
{
"query": {
"bool": {
"must": [
{
"term": { "_type": "orderbook" }
},
{
"nested": {
"path": "orders",
"query": {
"match_all": {}
},
"inner_hits": {
"size": 2
}
}
}
]
}
}}