PGroonga 2. Make PostgreSQL rich full text search system backend!

Similar documents
Cloud Connector 徹底解説. 多様な基盤への展開を可能にするための Citrix Cloud のキーコンポーネント A-5 セールスエンジニアリング本部パートナー SE 部リードシステムズエンジニア. 哲司 (Satoshi Komiyama) Citrix

Unofficial Redmine Cooking - QA #782 yaml_db を使った DB のマイグレーションで失敗する

本書について... 7 本文中の表記について... 7 マークについて... 7 MTCE をインストールする前に... 7 ご注意... 7 推奨 PC 仕様... 8 MTCE をインストールする... 9 MTCE をアンインストールする... 11

MySQL Cluster 7.3 リリース記念!! 5 分で作る MySQL Cluster 環境

Introduction to Information and Communication Technology (a)

今日の予定 1. 展開図の基礎的な知識 1. 正多面体の共通の展開図. 2. 複数の箱が折れる共通の展開図 :2 時間目 3. Rep-Cube: 最新の話題 4. 正多面体に近い立体と正 4 面体の共通の展開図 5. ペタル型の紙で折るピラミッド型 :2 時間目 ~3 時間目

Yamaha Steinberg USB Driver V for Mac Release Notes

Androidプログラミング 2 回目 迫紀徳

Googleの強みは ささえるのは世界一のインフラ. Google File System 2008年度後期 情報システム構成論2 第10回 クラウドと協調フィルタリング. 初期(1999年)の Googleクラスタ. 最近のデータセンタ Google Chrome Comicより

J の Lab システムの舞台裏 - パワーポイントはいらない -

PCIe SSD PACC EP P3700 Intel Solid-State Drive Data Center Tool

WD/CD/DIS/FDIS stage

Yamaha Steinberg USB Driver V for Windows Release Notes

電脳梁山泊烏賊塾 構造体のサイズ. Visual Basic

Computer Programming I (Advanced)

A. 展開図とそこから折れる凸立体の研究 1. 複数の箱が折れる共通の展開図 2 通りの箱が折れる共通の展開図 3 通りの箱が折れる共通の展開図そして. 残された未解決問題たち 2. 正多面体の共通の展開図 3. 正多面体に近い立体と正 4 面体の共通の展開図 ( 予備 )

Methods to Detect Malicious MS Document File using File Structure Inspection

Quick Install Guide. Adaptec SCSI RAID 2120S Controller

携帯電話の 吸収率 (SAR) について / Specific Absorption Rate (SAR) of Mobile Phones

携帯電話の 吸収率 (SAR) について / Specific Absorption Rate (SAR) of Mobile Phones

PSLT Adobe Typekit Service (2016v1.1)

API サーバの URL. <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE COMPLIANCE_SCAN SYSTEM "

Agilent. IO Libraries Suite 16.3/16.2 簡易取扱説明書. [ IO Libraries Suite 最新版 ]

Relaxed Consistency models and software distributed memory. Computer Architecture Textbook pp.79-83

Yamaha Steinberg USB Driver V for Windows Release Notes

Certificate of Accreditation

PRODUCT DESCRIPTIONS AND METRICS

Snoop cache. AMANO, Hideharu, Keio University Textbook pp.40-60

Lecture 4 Branch & cut algorithm

楽天株式会社楽天技術研究所 Autumn The Seasar Foundation and the others all rights reserved.

Unified System Management Technology for Data Centres

UB-U01III/U02III/U03II User s Manual

Zabbix ログ解析方法. 2018/2/14 サイバートラスト株式会社 Linux/OSS 事業部技術統括部花島タケシ. Copyright Cybertrust Japan Co., Ltd. All rights reserved.

2. 集団の注目位置推定 提案手法では 複数の人物が同一の対象を注視している状況 置 を推定する手法を検討する この状況下では 図 1 のよう. 顔画像からそれぞれの注目位置を推定する ただし f は 1 枚 この仮説に基づいて 複数の人物を同時に撮影した低解像度顔

Studies of Large-Scale Data Visualization: EXTRAWING and Visual Data Mining

JASCO-HPLC Operating Manual. (Analytical HPLC)

Online Meetings with Zoom

~ ソフトウエア認証への取り組みと課題 ~

フラクタル 1 ( ジュリア集合 ) 解説 : ジュリア集合 ( 自己平方フラクタル ) 入力パラメータの例 ( 小さな数値の変化で模様が大きく変化します. Ar や Ai の数値を少しずつ変化させて描画する. ) プログラムコード. 2010, AGU, M.

Video Annotation and Retrieval Using Vague Shot Intervals

サーブレットと Android との連携. Generated by Foxit PDF Creator Foxit Software For evaluation only.

振込依頼書記入要領 Entry Guide for Direct Deposit Request Form

Certificate of Accreditation

MetaSMIL : A Description Language for Dynamic Integration of Multimedia Content

FUJITSU Software SystemcastWizard Professional V5.1 L30 ユーザーズガイド B7FW Z0(00) 2014 年 8 月

Vehicle Calibration Techniques Established and Substantiated for Motorcycles

Private Sub 終了 XToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 終了 XToolStripMenuItem.

Saki is a Japanese high school student who/ has just started to study/ in the US.//

Oracle Cloud で実現する DevOps

TOOLS for MR V1.7.7 for Mac Release Notes

DürrConnect the clever connection. The quick connection with the Click

サンプル. NI TestStand TM I: Introduction Course Manual

和英対訳版. IEC Standard Template のユーザーガイド 備考 : 英語原文掲載 URL ( 一財 ) 日本規格協会

MySQL 最新動向と便利ツール MySQL Workbench

HPE Insight Control サーバープロビジョニング 7.6 ビルドプランリファレンスガイド

Centralized (Indirect) switching networks. Computer Architecture AMANO, Hideharu

Quick Installation Manual

マルチビットアップセット耐性及びシングルビットアップセット耐性を備えた

BMW Head Up Display (HUD) Teardown BMW ヘッドアップディスプレイティアダウン

Web Billing User Guide

MathWorks Products and Prices Japan September 2016

Web 成績登録システム利用の手引き ( 改訂版 )


Infragistics ASP.NET リリースノート

Synchronization with shared memory. AMANO, Hideharu Textbook pp.60-68

UML. A Model Trasformation Environment for Embedded Control Software Design with Simulink Models and UML Models

船舶保安システムのセルフチェックリスト. Record No. Name of Ship 船名 flag 国籍 Name of Company 会社名 Date 点検日 Place 場所 Checked by 担当者名. MS-SELF-CHK-SHIP-j (2012.

Operational Precaution

IRS16: 4 byte ASN. Version: 1.0 Date: April 22, 2008 Cisco Systems 2008 Cisco, Inc. All rights reserved. Cisco Systems Japan

PNRGOV/Ver11.1/ 旅客氏名表予約情報報告 (PNR01)

暗い Lena トーンマッピング とは? 明るい Lena. 元の Lena. tone mapped. image. original. image. tone mapped. tone mapped image. image. original image. original.

NI TB Introduction. Conventions INSTALLATION INSTRUCTIONS Wire Terminal Block for the NI PXI-2529

IPv6 関連 WG の状況 (6man, v6ops, softwire)

NUC and its Applications

BABr11.5 for Linux のインストール 2007/12/21. You are running Linux on Kernel smp. Analyzing the environment

GEO Grid の概要とその IT 技術の現状 将来について

Industrial Solar Power PoE Switch

製 品 ガ イ ド NetShield for NetWare V E R S I O N 4. 6

IP Network Technology

Ritsu-Mate Registration Manual (for Undergraduate Programs)

Invitrogen Custom Primer Ordering Guide

Kazunari Okada( 岡田一成 ) Sr. Technical Marketing Manager ISO Vibration Analyst (CAT II) National Instruments Corporation Japan

SteelEye Protection Suite for Linux

Preparing Information Design-Oriented. Posters. easy to. easy to. See! Understand! easy to. Convey!

BraindumpStudy. BraindumpStudy Exam Dumps, High Pass Rate!

勧告第 16 号 UN/LOCODE- 港および地名コード ECE/TRADE/227

アルゴリズムの設計と解析 (W4022) 教授 : 黄潤和 広野史明 (A4/A8)

The Secret Life of Components

Specification Sheet for Network Upgrade for Data Center and Research

Clinical Data Acquisition Standards Harmonization (CDASH)

2018 年 2 月 16 日 インテル株式会社

TRACE32 Training... シンボルデータベース 内部シンボルデータベースの構造 シンボルデータベースの一般情報 シンボルブラウザ 選択したシンボルの詳細 ソースファイル内の検索...

ポータブルメディア機器向けプロセッサ フォトフレーム向けメディアプロセッサ

Verify99. Axis Systems

DCBDQuery Query Language for RDF using Dynamic Concise Bounded Description

User Guide. P6 Barcode Scanner. English 日本語

ご注意. (4) 運用した結果の影響につきましては (4) の項に関わらず責任を負いかねますのでご了承ください (5) Autodesk Device Interface(ADI) および Heidi Device Interface(HDI) ドライバは 周辺機器メーカーに対応しています

present on a local docker container to Kong. This special event is open only to Cisco Customers and Partners. This project contains sample code to be

tp.responsewriter, r *http.request) { /* Hmmm, I wonder if this main */ hosttokens := strings.split(r.host, ":"); if len(hosttok

Denso Lexus GS250 TCU Teardown

Transcription:

PGroonga 2 Make PostgreSQL rich full text search system backend! Kouhei Sutou ClearCode Inc. PGConf.ASIA 2017 2017-12-05

Targets 対象者 Want to implement full text search with PostgreSQL PostgreSQL で全文検索したい Not good at full text search 全文検索はよく知らない PGroonga 1.0.0 users PGroonga 1.0.0 は使ったことがある

Abbreviations 略語 PG: PostgreSQL ポスグレ : PostgreSQL FTS: Full text search FTS: 全文検索

FTS system: Targets 全文検索システム : 対象 Many tests 大量のテキスト e.g.: Text data in office docs in file servers 例 : ファイルサーバー内のオフィス文書内のテキスト e.g.: Item descriptions, chat logs, Wiki data,... 例 : 商品説明やチャットログ Wiki のデータなど

FTS system: Goal 全文検索システム : 目的 Provide needed info when you need 必要な情報を必要なときに提供すること

Provide needed info 必要な情報を提供 Not found 探している情報が見つからない Found 探している情報が見つかる Found unconscious needed info too! 意識していなかったけど実は欲しかった情報も見つかる!

When you need 必要なときに活用 Need many times to find なかなか見つからない Find in no time すぐに見つかる Already found すでに見つかっていた e.g.: Recommendation 例 : レコメンデーション

How to impl.: Options 実装方法 : 選択肢 Use FTS server 全文検索サーバーを使う Use PostgreSQL PostgreSQL を使う

FTS server: Pros 全文検索サーバー案 : メリット Provides all basic features 必要な機能が揃っている Provides advanced features +α の機能もある Fast 速い

FTS server: Cons1 全文検索サーバー案 : デメリット 1 Large implementation cost 実装コスト大 Learn how to use from scratch 使い方を 1 から学ぶ必要がある How to implement data sync? マスターデータの同期はどうする?

FTS server: Cons2 全文検索サーバー案 : デメリット 2 Large maintenance cost メンテナンスコスト大 Learn how to operate from scratch 運用方法を 1 から学ぶ必要がある

PostgreSQL: Pros1 PostgreSQL 案 : メリット 1 Less implementation cost 実装コスト小 Less things to be learned 新しく覚えることが少ない Can manage data at the same place データの一元管理

PostgreSQL: Pros2 PostgreSQL 案 : メリット 2 Less operation cost メンテナンスコスト小 The current operation knowledge is reusable 既存の運用ノウハウを使える

PostgreSQL: Cons PostgreSQL 案 : デメリット Built-in features aren't enough 組込機能では機能不足 SQL limits efficiency SQL の表現力不足 e.g.: SQL needs multiple queries for a process that can be done by 1 query by FTS server 例 : 全文検索サーバーなら 1 クエリーで実現できる処理に SQL だと複数クエリー必要なことがある

The 3rd option 第 3 の選択肢 Use FTS engine via PostgreSQL (SQL) PostgreSQL 経由 (SQL) で全文検索エンジンを使う

Pros メリット Fast and rich features 高速で豊富な機能 Less implementation cost 実装コスト小 Less operation cost メンテナンスコスト小

Cons デメリット Need PostgreSQL extension PostgreSQL に拡張機能が必要 Not available on DBaaS DBaaS で使えない

Option: No FTS knowledge オススメの選択肢 : 全文検索の知識ナシ Need only simple features まだ単純な機能で十分 Less data: LIKE with PostgreSQL データ少 :PostgreSQL で LIKE Need up-to-date FTS features いまどきの全文検索機能が必要 FTS engine via PostgreSQL PostgreSQL 経由で全文検索エンジン

Option: With FTS knowledge オススメの選択肢 : 全文検索の知識アリ Need tuned FTS feature カリカリにチューニングしたい PostgreSQL + FTS server PostgreSQL+ 全文検索サーバー Others それ以外 FTS engine via PostgreSQL PostgreSQL 経由で全文検索エンジン

Described option 説明する選択肢 FTS engine via PostgreSQL PostgreSQL 経由で全文検索エンジン

FTS engine: Groonga 全文検索エンジン :Groonga( ぐるんが ) Embeddable FTS engine 組込可能な全文検索エンジン PGroonga: Groonga in PostgreSQL PGroonga:PostgreSQL に組込 Usable as FTS server 全文検索サーバーとして単独でも使用可能 PostgreSQL + FTS server architecture is also available PostgreSQL+ 全文検索サーバー構成もできる

Groonga's hobby: data update Groonga の得意な事 : データの追加 更新 Make fresh data searchable! 新鮮な情報をすぐ検索可能! Batch update is needless バッチで更新しなくてもよい Can use as chat backend チャットくらいの頻度でも OK e.g.: Zulip uses PGroonga 例 :Zulip は PGroonga を採用

Groonga's hobby: data update Groonga の得意な事 : データの追加 更新 Keep search performance while updating! 更新中も検索性能が落ちない! Updatable when there are many search users 利用ユーザーが多い時でも更新可能

PGroonga PGroonga( ぴーじーるんが ) PostgreSQL index PostgreSQL のインデックス Alternative of GIN, RUM,... GIN RUM などと同じレイヤー Usage 使用方法 CREATE INDEX... USING PGroonga...

PostgreSQL and FTS PostgreSQL と全文検索 LIKE: Built-in( 組込機能 ) textsearch: Built-in( 組込機能 ) pg_trgm: Contrib( 標準添付 ) Bundled in the archive アーカイブには含まれている Need to install separately 別途インストールすれば使える

LIKE and performance LIKE と速度 Small data 少ないデータ Enough performance 十分実用的 Not small data 少なくないデータ Need to tune 性能問題アリ

LIKE and FTS system LIKE と全文検索システム Enough performance in most case 速度が実用的なことも多い Data are small in many case 少ないデータなら

LIKE and FTS system LIKE と全文検索システム Unable to sort それっぽい順のソート不可 Sort is important in FTS 全文検索ではソート順が重要 Users check only the first N entries ユーザーは先頭 N 件しか見ない

textsearch Fast search by index インデックスを作るので速い Need module for each lang 言語毎にモジュールが必要 Modules for English, French,... are built-in 英語やフランス語などは組込 Modules for languages in Asia aren't maintained アジア圏の言語用のモジュールはメンテされていない

pg_trgm Fast search by index インデックスを作るので速い Asian languages aren't enough supported アジア圏の言語のサポートは十分ではない Unable to sort それっぽい順のソート不可

RUM RUM = GIN + position RUM は位置情報付きの GIN https://github.com/postgrespro/rum pg_trgm/pg_bigm are slow for much matches case pg_trgm と pg_bigm はマッチ数が多いと遅くなる RUM will solve it GIN の代わりに RUM を使うことで解決できるかも!

PGroonga Fast search by index インデックスを作るので速い Sortable それっぽい順のソート可 Support all languages 全言語対応 Need to install separately 別途インストールする必要アリ

FTS system with PostgreSQL PostgreSQL で全文検索システム PGroonga is the best! PGroonga がベスト! PGroonga Fast( 高速 ) Support all langs( 全言語対応 ) Sortable( それっぽい順でソート可 )

FTS system: Basic features 全文検索システム : 基本機能 Fast FTS + sort 高速全文検索 + ソート Show texts around keyword キーワード周辺テキスト表示 Highlight keyword 検索キーワードハイライト

FTS system: Adv. features 全文検索システム : 高度な機能 Auto complete オートコンプリート Similar search 類似文書検索 Synonym expansion 同義語展開

PGroonga 1.0.0 are only supported 以下の機能のみ対応 Fast FTS + sort 高速全文検索 + ソート Show texts around keyword キーワード周辺テキスト表示

PGroonga 2 All features are supported! 全機能対応!

PGroonga 1.0.0 2 Many new features たくさんの新機能 Improve performance 性能改善 API is changed API が変わった

API change API 変更 Operator is changed 演算子変更 @@ &@~ %% &@...

API change API 変更 pgroonga schema is deprecated pgroonga スキーマを非推奨に pgroonga.score pgroonga_score pgroonga.flush pgroonga_flush...

App for PGroonga 1.0.0 PGroonga 1.0.0 用アプリ Broken with PGroonga 2? PGroonga 2 では動かない? No! Work without any changes! 何も変更しなくても動くよ! Great! But why? いいじゃん! でもなんで動くの? "Painless upgrade" technique

Painless upgrade PGroonga 2 provides both 1 API and 2 API PGroonga 2 は 1 用の API も 2 用の API も両方提供 Can use PGroonga 2 with 1 API PGroonga 1 の API で PGroonga 2 を使える

Painless upgrade The last PGroonga 1.X provides both 1 API and partially 2 API PGroonga 1 系の最終版は 1 用の API も 2 用の API の一部も提供 Can use PGroonga 1 with 2 API PGroonga 2 の API で PGroonga 1 を使える

Painless upgrade PGroonga 2 keeps 1 API PGroonga 2 の間は 1 の API を維持 PGroonga 3 will drop 1 API PGroonga 3 で 1 の API を削除予定 Just need to upgrade API until 3 PGroonga 3 までに API をアップグレードすればよい

Painless upgrade App for PGroonga 1.0.0 doesn't work with PGroonga 2 PGroonga 1.0.0 用のアプリが PGroonga 2 で動かない It's a bug. Please report it! バグなので報告してね!

FTS system: Basic features 全文検索システム : 基本機能 Fast FTS + sort 高速全文検索 + ソート Show texts around keyword キーワード周辺テキスト表示 Highlight keyword 検索キーワードハイライト

Fast FTS + sort 高速全文検索 + ソート

Table definition CREATE TABLE entries ( -- Need primary key -- It's needed for sort id integer PRIMARY KEY, title text, content text );

Index definition -- For FTS. -- The default is good enough! CREATE INDEX entries_full_text_search ON entries -- "USING PGroonga" is important! -- Primary key is for sort! USING PGroonga (id, title, content);

Insert data -- Normal INSERT. INSERT INTO entries VALUES (1, 'Fast FTS with Groonga!', 'Fast FTS is needed!');

FTS SELECT title FROM entries WHERE -- &@~ is for FTS -- AND search with "search" and "fast" title &@~ 'search fast' OR content &@~ 'search fast';

FTS: LIKE SELECT title FROM entries WHERE -- Index search for LIKE is supported -- = Improve app perf without any changes -- NOTE: &@~ is faster than LIKE title LIKE '%search%' OR content LIKE '%search%';

Sort SELECT title, -- pgroonga_score(table_name) returns -- precision as number pgroonga_score(entries) AS score FROM entries WHERE --... -- Sort by precision ORDER BY score DESC LIMIT 10;

Highlight keyword キーワードハイライト

Hightlight for HTML SELECT pgroonga_highlight_html( title, -- Extract keywords from query pgroonga_query_extract_keywords('search fast')) FROM entries WHERE title &@~ 'search fast' OR content &@~ 'search fast';

Highlight for HTML: Example Fast search with <Groonga>! <span class="keyword">fast</span> Keywords are marked up with "class" <span class="keyword">search</span>! with <Groonga>! Escape tag

Texts around keyword キーワード周辺テキスト

Texts around keyword for HTML SELECT pgroonga_snippet_html( content, -- Extract keywords from query pgroonga_query_extract_keywords('search fast')) FROM entries WHERE title &@~ 'search fast' OR content &@~ 'search fast';

Example...fast search with <Groonga>!... ARRAY[ First '<span class="keyword">fast</span> Keywords are marked up with "class" <span class="keyword">search/span>! with <Groonga>!', Escape tag '...' Second ]

FTS system: Adv. features 全文検索システム : 高度な機能 Auto complete オートコンプリート Similar search 類似文書検索 Synonym expansion 同義語展開

Auto complete オートコンプリート

Auto complete: Preparation オートコンプリート : 準備 Master table マスターテーブル Candidate 候補 :( 例 : 牛乳 ) Readings in Katakana (Only for Japanese) ヨミ ( 日本語の場合 カタカナ 複数登録可 ) 例 : ギュウニュウ ミルク

Auto complete: Implementation オートコンプリート : 実装方法 OR search with... Prefix search against readings (Only for Japanese) ヨミを前方一致検索 ( 日本語の場合 ) Loose FTS against candidate 候補をゆるく全文検索 Sort by candidate 候補でソート https://pgroonga.github.io/how-to/auto-complete.html

Table definition CREATE TABLE terms ( term text, -- Candidate readings text[], -- Readings );

Data example INSERT INTO terms VALUES ( 'milk', -- Candidate ARRAY[ -- Reading in Katakana ' ギュウニュウ ', -- "milk" in Japanese -- Multiple readings ] ); ' ミルク ' -- "milk" in Katakana

Data management データ管理 Easy to maintain because it's a normal table 普通のテーブルなので管理が楽 Easy to insert/delete/update 追加 削除 更新が楽 Normal backup and replication ダンプ リストアもレプリケーションもいつも通り

Index for prefix search 前方一致用インデックス CREATE INDEX prefix_search ON terms USING PGroonga --...text_array_term_search... (readings pgroonga_text_array_term_search_ops_v2);

Index for loose FTS 緩い全文検索用インデックス CREATE INDEX loose_search ON terms USING PGroonga (term) -- Tokenizer for loose full text search WITH (tokenizer='tokenbigramsplitsymbolalphadigit');

How to search 検索方法 SELECT term FROM terms -- Prefix search against readings WHERE readings &^~ '${INPUT}' OR -- Loose full text search term &@ '${INPUT}' ORDER BY term LIMIT 10; -- Sort

Search example: Candidate 検索例 : 候補 -- User inputs "il" SELECT term FROM terms -- Prefix search against readings WHERE readings &^~ 'il' OR -- Loose full text search (Hit) term &@ 'il' ORDER BY term LIMIT 10; -- Sort

Search example: Katakana 検索例 : カタカナ -- User inputs " ギュウ " SELECT term FROM terms -- Prefix search against readings (Hit) WHERE readings &^~ ' ギュウ ' OR -- Loose full text search term &@ ' ギュウ ' ORDER BY term LIMIT 10; -- Sort

Search example: Hiragana 検索例 : ひらがな -- User inputs " ぎゅう " SELECT term FROM terms -- Prefix search against readings (Hit) WHERE readings &^~ ' ぎゅう ' OR -- Loose full text search term &@ ' ぎゅう ' ORDER BY term LIMIT 10; -- Sort

Search example: Romaji 検索例 : ローマ字 -- User inputs "gyu" SELECT term FROM terms -- Prefix search against readings (Hit) WHERE readings &^~ 'gyu' OR -- Loose full text search term &@ 'gyu' ORDER BY term LIMIT 10; -- Sort

Synonym expansion 同義語展開 Synonym 同義語 Same mean but different notation 同じ意味だが表記が異なる語 e.g.: "PostgreSQL" and "PG" 例 : PostgreSQL と ポスグレ

Synonym expansion 同義語展開 Users don't want to care ユーザーは気にしたくない Synonym expansion 同義語展開 OR search with all synonyms 同義語すべてで OR 検索

Implementation 実装方法 Create synonym table 同義語管理テーブルを作成 Expand synonyms in query クエリー内の同義語を展開 Search by expanded query 展開後のクエリーで検索 https://pgroonga.github.io/reference/functions/ pgroonga-query-expand.html

Table definition CREATE TABLE synonyms ( -- Term to be expanded term text, -- Synonym list. -- Including the "term" itself. -- If you don't input the "term", -- the "term" is unsearchable term. terms text[] );

Data example INSERT INTO synonyms VALUES ('PostgreSQL', -- Expand "PostgreSQL" ARRAY['PostgreSQL', 'PG']), ('PG', -- Expand "PG" ARRAY['PG', 'PostgreSQL']);

Data management データ管理 Easy to maintain because it's a normal table 普通のテーブルなので管理が楽 Easy to insert/delete/update 追加 削除 更新が楽 Normal backup and replication ダンプ リストアもレプリケーションもいつも通り

Index definition CREATE INDEX synonym_search ON synonyms USING PGroonga --...text_term_search... -- For equal search (term pgroonga_text_term_search_ops_v2);

Confirm 確認方法 SELECT pgroonga_query_expand( 'synonyms', -- Table name 'term', -- Column name to be expanded 'terms', -- Column name for synonyms 'PostgreSQL' -- Query ); -- '((PostgreSQL) OR (PG))'

Search 検索方法 SELECT title FROM entries WHERE -- title &@~ 'DB ((PostgreSQL) OR (PG))' title &@~ pgroonga_query_expand('synonyms', 'term', 'terms', 'DB PostgreSQL');

Similar search 類似文書検索 Query is document itself 検索クエリーは文書そのもの Not keyword キーワードではない Use case 利用例 Show related entries 関連エントリーの提示に使える

Implementation 実現方法 Create dedicated index 類似検索用のインデックスを作る Use tokenizer for target language 対象の言語に合わせた処理で精度向上 e.g.: MeCab based tokenizer for Japanese 例 : 日本語なら MeCab ベースのトークナイザーを活用 Use dedicated operator 類似検索用の演算子を使う

Index definition CREATE INDEX entries_similar_search ON entries -- Target: Both title and content -- Reason: Title is important USING PGroonga (id, (title ' ' content)) -- TokenMecab is good for Japanese WITH (tokenizer='tokenmecab');

Search SELECT title, pgroonga_score(entries) AS score FROM entries WHERE -- &@* is operator for similar search. -- Search with existing document. (title ' ' content) &@* '...fast search with Groonga!...' ORDER BY score DESC LIMIT 3;

Result example 結果例 Query:...search with Groonga!... Hit example:...search with PGroonga!...

Wrap up: Basic features 全文検索システム : 基本機能 Fast FTS + sort 高速全文検索 + ソート Show texts around keyword キーワード周辺テキスト表示 Highlight keyword 検索キーワードハイライト

Wrap up: Adv. features 全文検索システム : 高度な機能 Auto complete オートコンプリート Similar search 類似文書検索 Synonym expansion 同義語展開

FTS system: Next step 全文検索システム : 次の一歩 Support structured data 構造化データ対応 Office document, HTML,... オフィス文書 HTML など Needed features 対応に必要な処理 Text/metadata extraction テキスト メタデータ抽出 Create screenshot スクリーンショット作成

Apache Tika Extraction tool 抽出ツール Apache Lucene's subproject Many supported formats 対応フォーマットが多い ChupaText Groonga's subproject Screenshot support スクリーンショット作成対応

ChupaText Supported formats( 対応フォーマット ) Word/Excel/PowerPoint ODT/ODS/ODP(OpenDocument) PDF/HTML/XML/CSV/... Interface( インターフェイス ) HTTP and command line HTTP とコマンドライン

Install インストール Use Docker or Vagrant Docker か Vagrant を使うのが楽 https://github.com/ranguba/chupa-text-docker https://github.com/ranguba/chupa-text-vagrant

ChupaText:Docker % GITHUB=https://github.com % git clone \ ${GITHUB}/ranguba/chupa-text-docker.git % cd chupa-text-docker % docker-compose up --build

Usage 使い方 % curl \ --form data=@xxx.pdf \ http://localhost:20080/extraction.json

Result example 結果例 { "mime-type": "application/pdf", # MIME type for the original data "size": 147159, # Metadata..., "texts": [ # Extracted texts { "mime-type": "text/plain", # MIME type for the extracted data..., "creator": "Adobe Illustrator CS3", # Metadata "body": "This is sample PDF....", # Extracted text "screenshot": { "mime-type": "image/png", # MIME type for screenshot "data": "ivborw...", # Base64-ed image data "encoding": "base64" } } ] }

Web UI

Web UI: Extraction example Web UI: 抽出例

Web UI: Extraction example Web UI: 抽出例

ChupaText:Vagrant % GITHUB=https://github.com % git clone \ ${GITHUB}/ranguba/chupa-text-vagrant.git % cd chupa-text-vagrant % vagrant up Usage is the same as Docker's 使い方は Docker 版と同じ

Use cases( 活用例 ) Extracted text Insert into PGroonga Extracted metadata Insert into PGroonga Use for condition( 絞り込みに活用 ) Created screenshot Show in search result( 検索結果で表示 )

Wrap up まとめ FTS engine via PostgreSQL PostgreSQL 経由で全文検索エンジン Provide decision info 採用の判断材料を提供

Wrap up まとめ Show how to impl. FTS system 全文検索システム実装例を紹介 PGroonga PGroonga 1.0.0 and 2 PGroonga 1.0.0 と 2 Painless upgrade

Wrap up まとめ Show how to support structured data 構造化データの対応方法を紹介 ChupaText

Support service サポートサービス紹介 Install support( 導入支援 ) 設計支援 性能検証 移行支援 Development support( 開発支援 ) サンプルコード提供 問い合わせ対応 Operation support( 運用支援 ) 障害対応 チューニング支援 Contact( 問い合わせ先 ) https://www.clear-code.com/contact/? type=groonga