Elasticsearch 學習之Field Collapsing(欄位摺疊)
阿新 • • 發佈:2018-11-11
Field Collapsing(欄位摺疊)不能與scroll、rescore以及search after 結合使用
- collapse欄位:表示按照age(每個age對應多條document結果)的值摺疊(keyword或者數值)
- sort:表示按照age欄位排序
from:偏移,即前180個document的值都被摺疊掉了
curl -XGET "http://localhost:9200/bank/_search" -H 'Content-Type: application/json' -d' { "query": { "match": { "address": "Place" } }, "collapse" : { "field" : "age" }, "sort": ["age"], "from": 10 }''
Expand collapse results(對於每個摺疊的結果,可以通過inner_hits展開結果)
- max_concurrent_group_searches:允許每組檢索inner_hits的併發請求數 (預設按照執行緒池的大小或者資料節點數)
單個inner_hits
curl -XGET "http://localhost:9200/bank/_search" -H 'Content-Type: application/json' -d' { "query": { "match": { "address": "Place" } }, "collapse" : { "field" : "age", "inner_hits": { "name": "test", "size": 5, "sort": [{ "age": "asc" }] }, "max_concurrent_group_searches": 4 }, "sort": ["age"] }'
多個inner_hits
curl -XGET "http://localhost:9200/bank/_search" -H 'Content-Type: application/json' -d' { "query": { "match": { "address": "Place" } }, "collapse" : { "field" : "age", "inner_hits":[ { "name": "age", "size": 2, "sort": [{ "age": "asc" }] }, { "name":"account_number", "size": 2, "sort": [{ "account_number": "asc" }] }], "max_concurrent_group_searches": 4 }, "sort": ["age"] }'