---
title: CEL を活用した ABEMA のコンテンツ選定
tags:  #cel #推薦  
author: [坂田 淳樹](https://www.docswell.com/user/SakataAtsuki)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/Y76QW3K17V.jpg?width=480
description: 【登壇者情報】  坂田 淳樹（さかた あつき）  バックエンドエンジニア  2023 年新卒 株式会社サイバーエージェント ABEMA のコンテンツ推薦をメインに従事
published: January 18, 25
canonical: https://www.docswell.com/s/SakataAtsuki/KDN99L-cel-abema
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/Y76QW3K17V.jpg)

2025 January 18th
CEL を活用した
ABEMA のコンテンツ選定
株式会社サイバーエージェント
坂田 淳樹
AbemaTV, Inc. All Rights Reserved
1


# Page. 2

![Page Image](https://bcdn.docswell.com/page/G75RMLPLE4.jpg)

Profile
坂田 淳樹 （さかた あつき）
バックエンドエンジニア
2023 年新卒
株式会社サイバーエージェント
ABEMA のコンテンツ推薦をメインに従事
よく使う技術: Go, Google Cloud, Kubernetes
福岡県北九州市 出身
AbemaTV, Inc. All Rights Reserved
2


# Page. 3

![Page Image](https://bcdn.docswell.com/page/9J2D9L63JR.jpg)

INDEX
1. CEL とは
2. ABEMA での活用例
AbemaTV, Inc. All Rights Reserved
3


# Page. 4

![Page Image](https://bcdn.docswell.com/page/DEY24Q98EM.jpg)

CEL とは
AbemaTV, Inc. All Rights Reserved
4


# Page. 5

![Page Image](https://bcdn.docswell.com/page/VJN8YKL978.jpg)

CEL とは
Google が開発した軽量で高速な式評価言語。
user 1
{
“age”: 30,
“address”: “fukuoka”
}
user 2
{
“age”: 40,
“address”: “tokyo”
}
user 3
{
“age”: 25,
“address”: “osaka”
}
user 4
{
“age”: 35,
“address”: “fukuoka”
}
age &gt;= 30 &amp;&amp; address == “fukuoka”
user 1
{
“age”: 30,
“address”: “fukuoka”
}
user 4
{
“age”: 35,
“address”: “fukuoka”
}
AbemaTV, Inc. All Rights Reserved
5


# Page. 6

![Page Image](https://bcdn.docswell.com/page/YE9KPV43E3.jpg)

CEL の活用例
セキュリティとアクセス制御
Kubernetes での活用
イベント処理とフィルタリング
IAM や Firestore ルールでの認可条件
カスタムリソース定義でのバリデーション
メッセージやイベントを条件に基づいて効
やアクセス制御。
ロジックやポリシーチェック。
率的に評価・フィルタリング。
AbemaTV, Inc. All Rights Reserved
6


# Page. 7

![Page Image](https://bcdn.docswell.com/page/GE8RDPQLJD.jpg)

CEL の活用例
【ABEMA のコンテンツ選定の課題感】
コンテンツは手動で設定されていた。
または要件ごとに都度開発が必要だった。
イベント処理とフィルタリング
メッセージやイベントを条件に基づいて効
CEL を活用したフィルタリングによって
コンテンツ選定が柔軟になると考えた。
率的に評価・フィルタリング。
AbemaTV, Inc. All Rights Reserved
7


# Page. 8

![Page Image](https://bcdn.docswell.com/page/LELKM1XQJR.jpg)

CEL の特徴
シンプルで直感的な構文
高速な評価エンジン
式評価が速いため大量のデータに対応可能 。
読み書きしやすい。
例
contentType == “series” &amp;&amp; genreID == “animation”
型安全性
静的型チェックにより実行前にエラーを検出 。
豊富な機能セット
比較演算、リスト・マップ操作、正規表現、カスタム関
数をサポート。
AbemaTV, Inc. All Rights Reserved
8


# Page. 9

![Page Image](https://bcdn.docswell.com/page/4JM2YW3KJW.jpg)

CEL の処理プロセス
1.
構文解析 (Parse)
抽象構文木 (AST) を生成。
2.
型チェック (Check)
型安全性を確認し、実行前にエラーを排除。
3.
評価 (Evaluate)
ref: https://codelabs.developers.google.com/codelabs/cel-go?hl=ja#1
型チェック済みの AST を元に評価を実行。
AbemaTV, Inc. All Rights Reserved
9


# Page. 10

![Page Image](https://bcdn.docswell.com/page/PJRM9YQ6E9.jpg)

ABEMA での活用例
AbemaTV, Inc. All Rights Reserved
10


# Page. 11

![Page Image](https://bcdn.docswell.com/page/PEXVQG5D7X.jpg)

用語の説明
コンテンツ : 番組（例: シリーズ、シーズン、エピソード）
モジュール : 何らかの条件を満たすコンテンツの集合-ァ
ホーム面
視聴面
テレビ番組ランキング
ユーザーが
再生中のコンテンツ
放送中
AbemaTV, Inc. All Rights Reserved


# Page. 12

![Page Image](https://bcdn.docswell.com/page/3EKQ946DED.jpg)

システムの概要
1.
コンテンツの全キャッシュ
すべてのコンテンツをアプリケーション側に事前キャッシュし、即時アクセスを可能 に。
2.
CEL 式の管理画面入稿
管理者が条件を CEL 式として記述し、即座に適用。
CEL 式とソート順を指定し、コンパイルエラーを検出可能 に。
3.
動的評価
リクエスト時に CEL 式を評価し、コンテンツを表示。
AbemaTV, Inc. All Rights Reserved
12


# Page. 13

![Page Image](https://bcdn.docswell.com/page/L73PWL6PE5.jpg)

CEL 式の入稿例
1.
コンテンツの型定義
cel.NewEnv(
cel.Variable(&quot;contentType&quot;, cel.StringType),
cel.Variable(&quot;seriesID&quot;, cel.StringType),
cel.Variable(&quot;genreID&quot;, cel.StringType),
cel.Variable(&quot;startAt&quot;, cel.IntType),
cel.Variable(&quot;endAt&quot;, cel.IntType),
)
あるシリーズのエピソード一覧
contentType == “episode” &amp;&amp; seriesID == “シリーズID”
ソート順: エピソード No. 昇順
AbemaTV, Inc. All Rights Reserved
13


# Page. 14

![Page Image](https://bcdn.docswell.com/page/87DLKNV3EG.jpg)

CEL 式の入稿例
2.
コンテンツの型定義
cel.NewEnv(
cel.Variable(&quot;contentType&quot;, cel.StringType),
cel.Variable(&quot;seriesID&quot;, cel.StringType),
cel.Variable(&quot;genreID&quot;, cel.StringType),
cel.Variable(&quot;startAt&quot;, cel.IntType),
cel.Variable(&quot;endAt&quot;, cel.IntType),
)
アニメランキング
contentType == “series” &amp;&amp; genreID == “animation”
ソート順: 視聴数 降順
AbemaTV, Inc. All Rights Reserved
14


# Page. 15

![Page Image](https://bcdn.docswell.com/page/VJP2K5VPJ8.jpg)

CEL 式の入稿例
3.
コンテンツの型定義
cel.NewEnv(
cel.Variable(&quot;contentType&quot;, cel.StringType),
cel.Variable(&quot;seriesID&quot;, cel.StringType),
cel.Variable(&quot;genreID&quot;, cel.StringType),
cel.Variable(&quot;startAt&quot;, cel.IntType),
cel.Variable(&quot;endAt&quot;, cel.IntType),
)
放送中
contentType == “slot”
&amp;&amp; startAt &lt;= now() &amp;&amp; now() &lt; endAt
ソート順: 再生開始日時 昇順
※ now() の部分を現在時刻にリプレイスして評価しています。
AbemaTV, Inc. All Rights Reserved
15


# Page. 16

![Page Image](https://bcdn.docswell.com/page/2EVDVPZVEQ.jpg)

導入の利点
運用負荷軽減
柔軟性向上
パフォーマンスを維持
ビジネス側で直接運用が可能。
開発なしに条件を動的に更新できる。
CEL の高速な式評価。
AbemaTV, Inc. All Rights Reserved
16


# Page. 17

![Page Image](https://bcdn.docswell.com/page/57GYLP417L.jpg)

AbemaTV, Inc. All Rights Reserved


