日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

07.德国博士练习_09_agg_query

發(fā)布時間:2024/2/28 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 07.德国博士练习_09_agg_query 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

    • 1. exercise01: metric bucket pipeline

1. exercise01: metric bucket pipeline

# ** EXAM OBJECTIVE: AGGREGATIONS ** # GOAL: Create metrics, bucket, and pipeline aggregations # REQUIRED SETUP: # (i) a running Elasticsearch cluster with at least one node and a # Kibana instance, # (ii) add the "Sample flight data" to Kibana### Run the next querieson the `kibana_sample_data_flights` index # Create an aggregation named "max_distance" that calculates the # maximum value of the `DistanceKilometers` field# Create an aggregation named "stats_flight_time" that computes # stats over the value of the `FlightTimeMin` field# Create two aggregations, named "cardinality_origin_cities" and # "cardinality_dest_cities", that count the distinct values of # the `OriginCityName` and `DestCityName` fields, respectivelyGET kibana_sample_data_flights/_search { "size": 0, "aggs": {"max_distance": {"max": {"field": "DistanceKilometers"}},"stats_flight_time":{"stats": {"field": "FlightTimeMin"}},"cardinality_origin_cities":{"cardinality": {"field": "OriginCityName"}},"cardinality_dest_cities":{"cardinality": {"field": "DestCityName"}}} } # Create an aggregation named "popular_origin_cities" that # calculates the number of flights grouped by the `OriginCityName` field # As above, but return only 5 buckets and in descending order# Create an aggregation named "avg_price_histogram" that groups the # documents based on `AvgTicketPrice` by intervals of 250GET kibana_sample_data_flights/_search {"size": 0,"aggs": {"popular_origin_cities": {"terms": {"field": "OriginCityName","size": 5,"order": {"_count": "desc"}}},"avg_price_histogram":{"histogram": {"field": "AvgTicketPrice","interval": 250}}} } # Create an aggregation named "popular_carriers" that calculates the # number of flights grouped by the `Carrier` field# Add a sub-aggregation to "popular_carriers", named # "carrier_stats_delay", that computes stats over the value of the # `FlightDelayMin` field for the related bucket of carriers# Add a second sub-aggregation to "popular_carriers", named # "carrier_max_delay", that shows the flight having the maximum # value of the `FlightDelayMin` field for the related bucket of carriersGET kibana_sample_data_flights/_search {"size": 0,"aggs": {"popular_carriers":{"terms": {"field": "Carrier","size": 10},"aggs": {"carrier_stats_delay": {"stats": {"field": "FlightDelayMin"}},"carrier_max_delay":{"max": {"field": "FlightDelayMin"}}}}} } # Use the `timestamp` field to create an aggregation named # "flights_every_10_days" that groups the number of flights by an # interval of 10 days# Use the `timestamp` field to create an aggregation named # "flights_by_day" that groups the number of flights by day# Add a sub-aggregation to “flights_by_day”, named # “destinations_by_day”, that groups the day buckets by the value of the `DestCityName` field# Add a sub-aggregation to the sub-aggregation # "destinations_by_day", named "popular_destinations_by_day", that # returns the 3 most popular documents for each bucket (i.e., # ordered by their score)# Update “popular_destinations_by_day” to display only the # `DestCityName` field in for each top hit objectGET kibana_sample_data_flights/_search {"size": 0,"aggs": {"flights_every_10_days": {"date_histogram": {"field": "timestamp","fixed_interval": "10d"}},"flights_by_day": {"date_histogram": {"field": "timestamp","calendar_interval": "day"},"aggs": {"destinations_by_day": {"terms": {"field": "DestCityName","size": 10},"aggs": {"popular_destinations_by_day": {"top_hits": {"size": 3,"_source": {"includes": ["DestCityName"]}}}}}}}} } # Remove the "popular_destinations_by_day” sub-sub-aggregation from # “flights_by_day”# Add a pipeline aggregation to "flights_by_day", named # "most_popular_destination_of_the_day", that identifies the # "popular_destinations_by_day” bucket with the most documents for each day感覺這里好像有點問題,用的好像不是很對 對的,因為有一個特殊的path叫_count, 是特殊的,要注意 GET kibana_sample_data_flights/_search {"size": 0,"aggs": {"flights_every_10_days": {"date_histogram": {"field": "timestamp","fixed_interval": "10d"}},"flights_by_day": {"date_histogram": {"field": "timestamp","calendar_interval": "day"},"aggs": {"destinations_by_day": {"terms": {"field": "DestCityName","size": 10}},"most_popular_destination_of_the_day":{"max_bucket": {"buckets_path": "destinations_by_day._count"}}}}} } # Add a pipeline aggregation named "day_with_most_flights" that # identifies the “flights_by_day” bucket with the most documents# Add a pipeline aggregation named # "day_with_the_most_popular_destination_over_all_days" that # identifies the “flights_by_day” bucket with the largest # “most_popular_destination_of_the_day” valueGET kibana_sample_data_flights/_search {"size": 0,"aggs": {"flights_every_10_days": {"date_histogram": {"field": "timestamp","fixed_interval": "10d"}},"flights_by_day": {"date_histogram": {"field": "timestamp","calendar_interval": "day"},"aggs": {"destinations_by_day": {"terms": {"field": "DestCityName","size": 10}},"most_popular_destination_of_the_day": {"max_bucket": {"buckets_path": "destinations_by_day._count"}}}},"day_with_most_flights": {"max_bucket": {"buckets_path": "flights_by_day._count"}}} }

總結

以上是生活随笔為你收集整理的07.德国博士练习_09_agg_query的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。