postgresql의 한국어 검색 확장
341
textsearch_ko Repo의 내용을 그대로 PostgreSQL에 설치한 이미지입니다.
다음 dockerfile로 생성할 수 있습니다
ARG POSTGRES_VERSION="14"
FROM postgres:$POSTGRES_VERSION-bullseye
ARG POSTGRES_VERSION
# 데이터베이스 동기화 파일 전송
RUN apt update \
&& apt install -y build-essential git wget autoconf postgresql-server-dev-$POSTGRES_VERSION
# Mecab Ko 설치
RUN git clone https://bitbucket.org/eunjeon/mecab-ko.git \
&& cd mecab-ko \
&& wget 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' -O config.guess \
&& wget 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' -O config.sub \
&& ./configure \
&& make all \
&& make install
# Mecab Ko Dict 설치
RUN wget https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz \
&& tar xzf mecab-ko-dic-2.1.1-20180720.tar.gz \
&& cd mecab-ko-dic-2.1.1-20180720 \
&& ldconfig \
&& ldconfig -p | grep /usr/local/lib \
&& autoreconf \
&& ./configure \
&& make all \
&& make install
# Postgresql Extention 설치
RUN git clone https://github.com/i0seph/textsearch_ko.git \
&& cd textsearch_ko \
&& make USE_PGXS=1 \
&& make USE_PGXS=1 install
# Cleaning
RUN apt-get remove -y build-essential git wget autoconf
RUN rm -rf mecab-*
EXPOSE 5432
CMD ["postgres"]
Enter docker container bash
create cluster, install textsearch_ko and connect to psql
pg_createcluster 14 main
service postgresql start
su postgres
psql -f textsearch_ko/ts_mecab_ko.sql
psql
set default_text_search_config = korean;
select * from mecabko_analyze('무궁화꽃이 피었습니다.');
select * from to_tsvector('무궁화꽃이 피었습니다.');
Content type
Image
Digest
Size
523.4 MB
Last updated
over 4 years ago
docker pull karoid/postgres-textsearch_ko