UGA Boxxx

つぶやきの延長のつもりで、知ったこと思ったこと書いてます

【Kibana】JSON input ってどう使うの?

Kibana の JSON input の使い方を調べる

f:id:uggds:20200122002922p:plain:w300

www.elastic.co

簡単な説明は上のドキュメントより

JSON Input
A text field where you can add specific JSON-formatted properties to merge with the aggregation definition, as in the following example:
{ "script" : "doc['grade'].value * 1.2" }

上の例はgradeフィールドを1.2倍にして表示している
こんな風につかうらしい

他にどういうjsonのオプションが使えるのか

Aggregationの種類分あるみたい

Avg Aggregation
https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-aggregations-metrics-avg-aggregation.html

Sum Aggregation
https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-aggregations-metrics-sum-aggregation.html


https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-aggregations-metrics.html

気になる検証

A: filedではpriceを指定し、scriptではratingの値を指定して平均値を算出する
B: filedでratingを指定して平均値を算出する

この場合、AとBに違いがでるのか?

f:id:uggds:20200121235742p:plain:w300
f:id:uggds:20200121235824p:plain:w300

どちらもratingの平均値だが、微妙に違った

f:id:uggds:20200122000548p:plain:w400

考えてみたが、Aはpriceで集約してratingの平均値を計算しているので、priceがnullの場合は結果に含まれない
その違いで平均値が変わってくることがわかった