Open djklim87 opened 3 months ago
{
"query": "*",
"max_hits": 0,
"aggs": {
"comment_ranking_avg": {
"terms": {
"field": "comment_ranking",
"size": 20,
"order": {
"avg_field": "desc",
"_key": "desc"
}
},
"aggs": {
"avg_field": {
"avg": {
"field": "author_comment_count"
}
}
}
}
}
}
This is not a correct way to define the order. It should be:
"order": [ { "avg_field": "desc" }, { "_key":"desc" } ]
But currently this is not supported, only sort by one field is supported currently.
Provided order is not working also, but it's still not implemented
curl --location 'http://127.0.0.1:7280/api/v1/hn_small/search' \
--header 'Content-Type: application/json' \
--data '{
"query": "*",
"max_hits": 0,
"aggs": {
"comment_ranking_avg": {
"terms": {
"field": "comment_ranking",
"size": 20,
"order": [
{
"avg_field": "desc"
},
{
"_key": "desc"
}
]
},
"aggs": {
"avg_field": {
"avg": {
"field": "author_comment_count"
}
}
}
}
}
}'
{
"message": "invalid aggregation request: invalid type: sequence, expected a map at line 1 column 180"
}
So with an order by one key, it works fine and gives the same results each call.
Probably you just should notice somewhere in docs that you support now only one argument for sorting.
@PSeitz will the issue be closed with the merged PR https://github.com/quickwit-oss/quickwit/pull/5121 ?
There's also https://github.com/quickwit-oss/tantivy/pull/2451
But it's just covering error handling, not implementing order by multiple fields
Describe the bug
When we request collection with aggregation with sorting by two fields we see two bugs:
Steps to reproduce (if applicable)
quickwit/quickwit:0.8.1
curl -s -XPOST "${HOST}/api/v1/indexes" \ --header "content-type: application/yaml" \ --data-binary @./index-config.yaml
split -l 10000 ./data.jsonl ./data_splitted.
echo "Starting loading" for f in ./data_splitted.*; do echo "Upload chunk $f" curl -s -XPOST "${HOST}/api/v1/hn_small/ingest?commit=force" --data-binary @$f rm $f done echo "Finished"
curl --location '${HOST}/api/v1/hn_small/search' \ --header 'Content-Type: application/json' \ --data '{"query":"*","max_hits":0,"aggs":{"comment_ranking_avg":{"terms":{"field":"comment_ranking","size":20,"order":{"avg_field":"desc","_key":"desc"}},"aggs":{"avg_field":{"avg":{"field":"author_comment_count"}}}}}}'
{ "num_hits": 1165439, "hits": [], "elapsed_time_micros": 6665, "errors": [], "aggregations": { "comment_ranking_avg": { "buckets": [ { "avg_field": { "value": 3504.0 }, "doc_count": 1, "key": 928.0 # Should be 2nd }, { "avg_field": { "value": 3504.0 }, "doc_count": 1, "key": 961.0 # Should be 1st }, { "avg_field": { "value": 3504.0 }, "doc_count": 1, "key": 730.0 }, .....
{ "num_hits": 1165439, "hits": [], "elapsed_time_micros": 9610, "errors": [], "aggregations": { "comment_ranking_avg": { "buckets": [ { "avg_field": { "value": 64.0 }, "doc_count": 1, "key": 1305.0 }, { "avg_field": { "value": 117.0 }, "doc_count": 1, "key": 1296.0 }, { "avg_field": { "value": 40.0 }, "doc_count": 1, "key": 1289.0 }, { "avg_field": { "value": 87.0 }, "doc_count": 1, "key": 1287.0 }, ......
"buckets": [ { "avg_field": { "value": 3504.0 }, "doc_count": 1, "key": 961.0 }, { "avg_field": { "value": 3080.0 }, "doc_count": 1, "key": 980.0 }, { "avg_field": { "value": 3077.0 }, "doc_count": 1, "key": 1176.0 },
{ "num_hits": 1165439, "hits": [], "elapsed_time_micros": 6665, "errors": [], "aggregations": { "comment_ranking_avg": { "buckets": [ { "avg_field": { "value": 3504.0 }, "doc_count": 1, "key": 961.0 }, { "avg_field": { "value": 3504.0 }, "doc_count": 1, "key": 928.0 }, { "avg_field": { "value": 3504.0 }, "doc_count": 1, "key": 730.0 }, .....
Quickwit 0.8.1 (aarch64-unknown-linux-gnu 2024-03-29T14:09:41Z e6c5396)
Provided in the attached archive)