0
複数の属性で文書をソートする方法があります。 同じ属性で同じ方法で集約バケットをソートする必要があります。これは可能ですか?ここで文書と同じ属性のElasticsearchバケットを並べ替えます。
は私のサンプル文書です:
curl -XGET 'localhost:9200/cars/cars/_search?pretty' -d'
{
"size": 0,
"aggregations" : {
"CARS" : {
"terms" : {
"script" : {
"inline" : "doc[\"make\"].value + \"_\" + doc[\"series\"].value",
"lang" : "painless"
}
},
"aggregations" : {
"make" : {
"terms" : { "field" : "make"}
},
"series" : {
"terms" : { "field" : "series" }
}
}
}
}
}
'
:ここ
curl -XPUT 'localhost:9200/cars/_mapping/cars?pretty' -H 'Content-Type: application/json' -d'
{
"properties": {
"make": {
"type": "text",
"fielddata": true
},
"series": {
"type": "text",
"fielddata": true
}
}
}
'
が集計バケットクエリです:ここで私が凝集することができるようにするにはtrueにfielddataを設定してい
curl -XPOST 'localhost:9200/_bulk?pretty' -H 'Content-Type:
application/json' -d'
{ "index" : { "_index" : "cars", "_type" : "cars", "_id" : "1" } }
{ "make":"BMW", "series":"3er", "doorCount": 4}
{ "index" : { "_index" : "cars", "_type" : "cars", "_id" : "2" } }
{ "make":"BMW", "series":"3er", "doorCount": 5}
{ "index" : { "_index" : "cars", "_type" : "cars", "_id" : "3" } }
{ "make":"Opel", "series":"Astra", "doorCount": 2}
{ "index" : { "_index" : "cars", "_type" : "cars", "_id" : "4" } }
{ "make":"Opel", "series":"Omega", "doorCount": 2}
'
makeとseriesでバケツを並べ替える方法はありますか?
、 {「作ります」 : "asc"} ] 'と書かれているので、注文バケットは最初にシリーズでソートされ、makeは2番目にソートされます –