PostgreSQL上で動く日本語全文検索エンジン
本家様 https://pgroonga.github.io/ja/

CentOS 7で配布されているpostgreSQLは9.2である。どうやら最新の
PGroonga(2.1)には対応してないようなのでソースから作ることにした。

MeCab

[root@c ~]# gzip -cd mecab-0.996.tar.gz | tar xf -
[root@c ~]# cd mecab-0.996
[root@c mecab-0.996]# ./configure
[root@c mecab-0.996]# make && make check && make instll

groonga

[root@c ~]# yum --enablerepo=epel install libstemmer-devel
[root@c ~]# cd src/
[root@c src]# curl -O https://packages.groonga.org/source/groonga/groonga-7.0.6.tar.gz
[root@c src]# gzip -cd groonga-7.0.6.tar.gz | tar xf -
[root@c src]# cd groonga-7.0.6
[root@c groonga-7.0.6]# export PATH=/usr/sbin:/usr/bin:/usr/local/bin
 
[root@c groonga-7.0.6]# ./configure --prefix=/opt/groonga --with-mecab --with-zlib 
(略
Paths:
  Install path prefix:   /opt/groonga
  Configuration file:    /opt/groonga/etc/groonga/groonga.conf
(略
groonga-httpd:
  enable:                yes
  default database path: /opt/groonga/var/lib/groonga/db/db
  PCRE:
(略
[root@c groonga-7.0.6]# make && make check && make install

*「--with-libstemmer」を付けたらエラーになった...

pgroonga

[root@c ~]# cd src/
[root@c src]# curl -O https://packages.groonga.org/source/pgroonga/pgroonga-2.0.2.tar.gz
[root@c src]# gzip -cd pgroonga-2.0.2.tar.gz | tar xf -
[root@c src]# cd pgroonga-2.0.2
[root@c pgroonga-2.0.2]# export PATH=/opt/pgsql/curt/bin:/usr/bin:/usr/local/bin
[root@c pgroonga-2.0.2]# export PKG_CONFIG_PATH=/opt/groonga/lib/pkgconfig
 
[root@c pgroonga-2.0.2]# which pg_config
/opt/pgsql/curt/bin/pg_config
 
[root@c pgroonga-2.0.2]# pkg-config --list-all |grep groonga
groonga                             Groonga - An Embeddable Fulltext Search Engine
 
[root@c pgroonga-2.0.2]# make
[root@c pgroonga-2.0.2]# make install
 :
/bin/mkdir -p '/opt/pgsql/v9.6.5/lib'
/bin/mkdir -p '/opt/pgsql/v9.6.5/share/extension'
/bin/mkdir -p '/opt/pgsql/v9.6.5/share/extension'
/bin/install -c -m 755  pgroonga.so '/opt/pgsql/v9.6.5/lib/pgroonga.so'
/bin/install -c -m 644 .//pgroonga.control '/opt/pgsql/v9.6.5/share/extension/'
/bin/install -c -m 644 .//data/pgroonga--2.0.1.sql .....  '/opt/pgsql/v9.6.5/share/extension/'
 :
/bin/mkdir -p '/opt/pgsql/v9.6.5/lib'
/bin/install -c -m 755  pgroonga_check.so '/opt/pgsql/v9.6.5/lib/pgroonga_check.so'
 :
[root@c pgroonga-2.0.2]#
 
[root@c ~]# echo /opt/groonga/lib > /etc/ld.so.conf.d/groonga.conf
[root@c ~]# /sbin/ldconfig

*postgreSQLへの場所らは pg_config にて行われる

PostgreSQL

[root@c ~]# su - postgres
 
-bash-4.2$ /opt/pgsql/curt/bin/createuser -p 54321 --interactive tsuser
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
-bash-4.2$
-bash-4.2$ /opt/pgsql/curt/bin/psql -p 54321 -l
                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges
-----------+----------+----------+---------+-------+-----------------------
 postgres  | postgres | UTF8     | C       | C     |
 template0 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
(3 rows)
 
-bash-4.2$
-bash-4.2$ /opt/pgsql/curt/bin/createdb -p 54321 -O tsuser pgroonga_test 'full-text search test'
-bash-4.2$ /opt/pgsql/curt/bin/psql -p 54321 -l
                               List of databases
     Name      |  Owner   | Encoding | Collate | Ctype |   Access privileges
---------------+----------+----------+---------+-------+-----------------------
 pgroonga_test | tsuser   | UTF8     | C       | C     |
 postgres      | postgres | UTF8     | C       | C     |
 template0     | postgres | UTF8     | C       | C     | =c/postgres          +
               |          |          |         |       | postgres=CTc/postgres
 template1     | postgres | UTF8     | C       | C     | =c/postgres          +
               |          |          |         |       | postgres=CTc/postgres
(4 rows)
 
-bash-4.2$
-bash-4.2$ /opt/pgsql/curt/bin/psql -p 54321 -U postgres -d pgroonga_test
psql (9.6.5)
Type "help" for help.
 
pgroonga_test=# CREATE EXTENSION pgroonga;
CREATE EXTENSION
pgroonga_test=# \q
-bash-4.2$
 
-bash-4.2$ /opt/pgsql/curt/bin/psql -p 54321 -U tsuser -d pgroonga_test
psql (9.6.5)
Type "help" for help.
 
pgroonga_test=> \dx
                                           List of installed extensions
   Name   | Version |   Schema   |                                  Description
----------+---------+------------+--------------------------------------------------------------------------------
 pgroonga | 2.0.1   | public     | Super fast and all languages supported full text search index based on Groonga
 plpgsql  | 1.0     | pg_catalog | PL/pgSQL procedural language
(2 rows)
 
pgroonga_test=> \q
-bash-4.2$

あとは
https://pgroonga.github.io/ja/tutorial/でテスト

pgroonga_test=> alter table bigdata add constraint bigdata_key primary key(id);

メモ

「windows10+postgreSQL10+pgroonga2.2」と
「CentOS7+postgreSQL10+pgroonga2.2」とでヒットしたものと、ヒット数にほぼ違いが無い。しかしスコアが大きく異なっている。OSの原因かな?


トップ   編集 添付 複製 名前変更     ヘルプ   最終更新のRSS
Last-modified: 2017-10-16 (月) 20:55:28 (6d)