![[25.14 新機能]LookMLでフィールドの同義語を定義できるパラメータ「synonyms」がリリースされました](https://images.ctfassets.net/ct0aopd36mqt/wp-thumbnail-e9ed1b9e358f861394fd4a5c0648e488/fe4241c93a7a105fc9c830ea8d84c393/looker-logo-google_1200x630.png)
[25.14 新機能]LookMLでフィールドの同義語を定義できるパラメータ「synonyms」がリリースされました
さがらです。
先日、Lookerの最新バージョンである25.14がリリースされました。
この25.14の新機能として、LookMLでフィールドの同義語を定義できるパラメータsynonyms
がリリースされました。
この機能を試してみたので、この内容についてまとめてみます。
定義方法
定義方法はとても簡単で、各dimension・measureを定義する際に以下のようにsynonyms
を定義すればOKです。
dimension: customer_id {
primary_key: yes
type: number
sql: ${TABLE}.customer_id ;;
label: "顧客ID"
synonyms: ["ID", "顧客番号"]
}
measure: average_number_of_orders {
type: average
sql: ${number_of_orders} ;;
label: "平均注文数"
synonyms: ["オーダーの平均", "平均オーダー数", "アベレージ"]
}
定義後のExploreの変化
Explore上では、特にsynonyms
が表示されることはありませんでした。
この仕様は公式Docにも言及があります。
Synonyms aren't surfaced in a Looker Explore but instead appear as part of a field's metadata when you use the Looker API to get information about a LookML model.
Gemini in LookerのConversational Analyticsで質問をしてみる
実際にConversational Analyticsを使って、synonyms
の効果が出ているかを確認してみます。
使用するview・Explore
以下のViewを参照するExploreを定義しておきます。
view: customers {
sql_table_name: `production.customers`
;;
drill_fields: [customer_id]
label: "顧客"
dimension: customer_id {
primary_key: yes
type: number
sql: ${TABLE}.customer_id ;;
label: "顧客ID"
synonyms: ["ID", "顧客番号"]
}
dimension: first_name {
type: string
sql: ${TABLE}.first_name ;;
label: "名"
synonyms: ["名前 (名)", "ファーストネーム"]
}
dimension_group: first_order {
type: time
timeframes: [
raw,
date,
week,
month,
quarter,
year
]
convert_tz: no
datatype: date
sql: ${TABLE}.first_order_date ;;
label: "初回注文"
synonyms: ["最初の注文", "初回購入"]
}
dimension: last_name {
type: string
sql: ${TABLE}.last_name ;;
label: "姓"
synonyms: ["名字", "苗字", "ラストネーム"]
}
dimension_group: most_recent_order {
type: time
timeframes: [
raw,
date,
week,
month,
quarter,
year
]
convert_tz: no
datatype: date
sql: ${TABLE}.most_recent_order_date ;;
label: "最終注文"
synonyms: ["最新の注文", "最終購入"]
}
dimension: number_of_orders {
type: number
sql: ${TABLE}.number_of_orders ;;
label: "注文数"
synonyms: ["注文回数", "オーダー数"]
}
dimension: is_ordered {
type: yesno
sql: ${number_of_orders} != 0 ;;
label: "注文経験あり"
synonyms: ["購入フラグ", "注文有無"]
}
measure: count {
type: count
drill_fields: [customer_id, last_name, first_name]
label: "顧客数"
synonyms: ["ユーザー数", "人数", "カスタマー数"]
}
measure: total_number_of_orders {
type: sum
sql: ${number_of_orders} ;;
label: "合計注文数"
synonyms: ["総注文数", "オーダー数", "受注件数"]
}
measure: average_number_of_orders {
type: average
sql: ${number_of_orders} ;;
label: "平均注文数"
synonyms: ["オーダーの平均", "平均オーダー数", "アベレージ"]
}
measure: active_customer_count {
type: count_distinct
sql: ${customer_id} ;;
filters: [is_ordered: "Yes"]
label: "購入顧客数"
synonyms: ["アクティブユーザー数", "購入者数"]
}
measure: max_number_of_orders {
type: max
sql: ${number_of_orders} ;;
label: "最大注文数"
synonyms: ["最多注文回数"]
}
measure: min_number_of_orders {
type: min
sql: ${number_of_orders} ;;
filters: [is_ordered: "Yes"]
label: "最小注文数(購入者のみ)"
synonyms: ["最低注文回数"]
}
measure: new_customer_count {
type: count
filters: [first_order_date: "last 30 days"]
label: "新規顧客数(直近30日)"
synonyms: ["最近の新規ユーザー"]
}
measure: repeat_customer_count {
type: count
filters: [number_of_orders: ">1"]
label: "リピート顧客数"
synonyms: ["リピーター数"]
}
measure: percentage_of_repeat_customers {
type: number
sql: ${repeat_customer_count} / NULLIF(${active_customer_count}, 0) ;;
value_format_name: percent_2
label: "リピート率"
synonyms: ["リピーター率"]
}
}
Conversational Analyticsで質問をしてみる
以下のようにそれぞれ質問を行ってみました。検証に用いたViewがシンプルなことも影響があるかもしれませんが、こちらの意図に合った結果を返してくれていることがわかります。
- 「アクティブユーザー数とリピーター数を月ごとに比較して」
- 「リピーター率が最も高いのは、どの初回購入月?」
- 「最多注文回数を記録した顧客の初回購入日はいつ?その顧客番号も教えて」
最後に
Looker 25.14の新機能である、LookMLでフィールドの同義語を定義できるパラメータsynonyms
を試してみました。
Lookerで定義したSemantic Layerを生成AIで活かすためには必須の機能だと思います!ぜひご活用ください。