From 92b702970350e0a1c3f02be2d83af0ca6ce2ca9d Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Mon, 24 Apr 2023 12:09:43 +0200 Subject: [PATCH] hw2 (part 1): done ex1, ex2, ex3a-b --- Assignment2_part1/queries/query3a.http | 38 ++++++++++++++++++++++++++ Assignment2_part1/queries/query3b.http | 37 +++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 Assignment2_part1/queries/query3a.http create mode 100644 Assignment2_part1/queries/query3b.http diff --git a/Assignment2_part1/queries/query3a.http b/Assignment2_part1/queries/query3a.http new file mode 100644 index 0000000..b27c608 --- /dev/null +++ b/Assignment2_part1/queries/query3a.http @@ -0,0 +1,38 @@ +GET /restaurants/_search +{ + "size": 0, + "query": { + "bool": { + "must": [ + { + "match": { + "ratingText": "Good" + } + } + ] + } + }, + "aggs": { + "votes_ranges": { + "range": { + "field": "votes", + "ranges": [ + { "from": 0, "to": 250 }, + { "from": 250, "to": 500 }, + { "from": 500, "to": 750 }, + { "from": 750, "to": 1000 } + ] + }, + "aggs": { + "min_cost": { + "min": { + "field": "averageCostForTwo" + } + }, + "max_cost": { + "max": { "field": "averageCostForTwo" } + } + } + } + } +} diff --git a/Assignment2_part1/queries/query3b.http b/Assignment2_part1/queries/query3b.http new file mode 100644 index 0000000..98df909 --- /dev/null +++ b/Assignment2_part1/queries/query3b.http @@ -0,0 +1,37 @@ +GET /restaurants/_search +{ + "size": 0, + "query": { + "range": { + "votes": { + "gte": 100 + } + } + }, + "aggs": { + "city_term": { + "terms": { + "field": "city.keyword", + "size": 10000, + "shard_size": 10000, + "min_doc_count": 10, + "order": { "_count": "desc" } + }, + "aggs": { + "avg_price": { + "avg": { + "field": "averageCostForTwo" + } + }, + "avg_price_bucket_sort": { + "bucket_sort": { + "sort": [ + { "avg_price": { "order": "desc" } } + ], + "size": 7 + } + } + } + } + } +}