본문 바로가기

DB

[ PostgreSQL ] PGroonga 설치 및 튜토리얼

[ PGroonga란 ]

Groonga : 임베디드 형식의 굉장히 빠른 full text search engine

PGroonga : PostgreSQL의 extension으로 Groonga를 사용한 새로운 인덱스 접근 방법을 제공합니다. 기존 PostgreSQL full text search와 같은 경우 영어만 지원이 되었지만, Pgroonga는 모든 언어에 대한 full text search를 지원합니다. 게다가 PGroonga는 JSON의 모든 텍스트 값에 대한 full text search를 지원합니다.

[ PGroonga 준비 ]

 

Install | PGroonga

Install There are packages for major platforms. You can install PGroonga easily. There are separated documents for these platforms. And there is a document for building PGroonga from source. Here are supported PostgreSQL versions: 12 13 14 15 16 17 If your

pgroonga.github.io

CREATE EXTENSION IF NOT EXISTS pgroonga;
CREATE INDEX content_search_index ON content USING pgroonga (title, description);

[ PGroonga Operator ]

1. &@ : 하나의 키워드에 대한 full text search

SELECT * FROM content WHERE title &@ '냉장고';

SELECT * FROM content WHERE title LIKE '%냉장고%';

LIKE operator와 &@ operator의 기능은 거의 동일합니다.

하지만 LIKE operator는 recheck 과정(인덱스 탐색 후 sequential 탐색)을 진행하기 때문에 &@보다 느립니다.

2. &@~ : Query syntax에 관한 full text search ex. or, and

SELECT * FROM content WHERE title &@~ '냉장고 OR 트롯';

[ PGroonga Score ]

ORDER BY를 통해 정확도가 높은 순서대로 검색 결과를 정렬할 수 있습니다.

CREATE TABLE score_content ( id integer PRIMARY KEY, title text, description text);
CREATE INDEX pgroonga_score_content_search_index ON score_content USING pgroonga(title, description);

SELECT * FROM content WHERE title &@ '냉장고' OR title &@ '트롯' ORDER BY pgroonga_score(tableoid, ctid);

 

Overview | PGroonga

Overview PGroonga is a PostgreSQL extension. PGroonga provides a new index access method that uses Groonga. Groonga is an embeddable super fast full text search engine. It can be embedded into MySQL. Mroonga is a storage engine that is based on Groonga. Gr

pgroonga.github.io

 

 

Tutorial | PGroonga

This document describes how to use PGroonga step by step. If you don't install PGroonga yet, install PGroonga before you read this document. You can use PGroonga as fast full text search index. You can also use PGroonga as more general index for equality c

pgroonga.github.io

 

 

How to integrate pgroonga with Java based Spring/Hibernate | PGroonga

This is a document for PGroonga 2.X and 3.X. See PGroonga 1.x document when you're using old PGroonga. There are three parts to the integration. First is notification to spring that a custom registration of functions is required. The second step is to regi

pgroonga.github.io

 

 

[PostgreSQL] 검색을 위한 Full Text Search

PostgreSQL에서 제공하는 Full Text Search 기능을 사용하여 검색 기능을 구현하는 방법을 알아봅니다.

kwanok.me

△ Pgroonga 동작원리는 해당 포스트가 도움이 많이 됐다.