PostgreSQL 中文全文检索 (使用zhparser) 记录踩坑过程
1: 系统已经安装了postgresql 数据 (不管有没有安装全,总之已经可以创建数据库,创建表,查询....了)
2:查看已安装的数据库版本
postgres=# select version();
version
----------------------------------------------------------------------------------------------------------
PostgreSQL 10.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
(1 row)
3: 需要安装(如果已经安装了就不用安装了,看好一共是3个 联系我QQ 820688215 可以互相学些PG)
yum -y install postgresql10-server postgresql10-contrib postgresql10-devel
4: 看一下自己的数据安装路径,然后配置环境变量
export PATH=/usr/pgsql-10/bin:$PATH
5:下载
安装SCWS
因为zhparser是基于SCWS(简易中文分词系统)开发的。所以必须首先安装SCWS。
·
自行创建安装目录
[root@jxstar-dev home]# wget http://www.xunsearch.com/scws/down/scws-1.2.2.tar.bz2 --2020-12-22 18:13:20-- http://www.xunsearch.com/scws/down/scws-1.2.2.tar.bz2 正在解析主机 www.xunsearch.com (www.xunsearch.com)... 202.75.214.12 正在连接 www.xunsearch.com (www.xunsearch.com)|202.75.214.12|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:435267 (425K) [text/plain] 正在保存至: “scws-1.2.2.tar.bz2” 100%[=======================================================================================================================================================>] 435,267 --.-K/s 用时 0.1s 2020-12-22 18:13:21 (2.80 MB/s) - 已保存 “scws-1.2.2.tar.bz2” [435267/435267])
[root@jxstar-dev home]# tar xvf scws-1.2.2.tar.bz2 scws-1.2.2/ scws-1.2.2/aclocal.m4 scws-1.2.2/API.md scws-1.2.2/AUTHORS scws-1.2.2/ChangeLog scws-1.2.2/cli/ scws-1.2.2/config.guess scws-1.2.2/config.h.in scws-1.2.2/config.sub scws-1.2.2/configure scws-1.2.2/configure.ac scws-1.2.2/COPYING scws-1.2.2/depcomp scws-1.2.2/etc/ scws-1.2.2/INSTALL scws-1.2.2/install-sh scws-1.2.2/libscws/ scws-1.2.2/ltmain.sh scws-1.2.2/Makefile.am scws-1.2.2/Makefile.in scws-1.2.2/missing scws-1.2.2/NEWS scws-1.2.2/phpext/ scws-1.2.2/README scws-1.2.2/win32/ scws-1.2.2/win32/libscws.dsp scws-1.2.2/win32/libscws.vcproj scws-1.2.2/win32/readme.txt scws-1.2.2/win32/scws.dsp scws-1.2.2/win32/scws.dsw scws-1.2.2/win32/scws.sln scws-1.2.2/win32/scws.vcproj scws-1.2.2/phpext/config.m4 scws-1.2.2/phpext/CREDITS scws-1.2.2/phpext/php_scws.c scws-1.2.2/phpext/php_scws.h scws-1.2.2/phpext/README.md scws-1.2.2/phpext/scws.php scws-1.2.2/phpext/scws_test.php scws-1.2.2/phpext/win32/ scws-1.2.2/phpext/win32/php_scws-1.2.2-win32.zip scws-1.2.2/phpext/win32/README.txt scws-1.2.2/libscws/charset.c scws-1.2.2/libscws/charset.h scws-1.2.2/libscws/config_win32.h scws-1.2.2/libscws/crc32.c scws-1.2.2/libscws/crc32.h scws-1.2.2/libscws/darray.c scws-1.2.2/libscws/darray.h scws-1.2.2/libscws/lock.c scws-1.2.2/libscws/lock.h scws-1.2.2/libscws/Makefile.am scws-1.2.2/libscws/Makefile.in scws-1.2.2/libscws/pool.c scws-1.2.2/libscws/pool.h scws-1.2.2/libscws/rule.c scws-1.2.2/libscws/rule.h scws-1.2.2/libscws/scws.c scws-1.2.2/libscws/scws.h scws-1.2.2/libscws/version.h scws-1.2.2/libscws/version.h.in scws-1.2.2/libscws/xdb.c scws-1.2.2/libscws/xdb.h scws-1.2.2/libscws/xdict.c scws-1.2.2/libscws/xdict.h scws-1.2.2/libscws/xtree.c scws-1.2.2/libscws/xtree.h scws-1.2.2/etc/Makefile.am scws-1.2.2/etc/Makefile.in scws-1.2.2/etc/rules.ini scws-1.2.2/etc/rules.utf8.ini scws-1.2.2/etc/rules_cht.utf8.ini scws-1.2.2/cli/gen_dict.c scws-1.2.2/cli/Makefile.am scws-1.2.2/cli/Makefile.in scws-1.2.2/cli/scws_cmd.c
//1>报错了!!!!!
[root@jxstar-dev scws-1.2.2]# ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for gcc... no //////////////////////////////////////// checking for cc... no ////////////////////////////////////////这三个没有安装 需要yum install gcc cc cl.exe checking for cl.exe... no //////////////////////////////////////// configure: error: in `/home/scws-1.2.2': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
再次执行正确
[root@jxstar-dev scws-1.2.2]# ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for a sed that does not truncate output... /usr/bin/sed checking whether ln -s works... yes checking whether make sets $(MAKE)... (cached) yes checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for a sed that does not truncate output... (cached) /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for fgrep... /usr/bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking the maximum length of command line arguments... 1572864 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking for /usr/bin/ld option to reload object files... -r checking how to recognize dependent libraries... pass_all checking for ar... ar checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no checking for logf in -lm... yes checking fcntl.h usability... yes checking fcntl.h presence... yes checking for fcntl.h... yes checking netinet/in.h usability... yes checking netinet/in.h presence... yes checking for netinet/in.h... yes checking math.h usability... yes checking math.h presence... yes checking for math.h... yes checking for stdlib.h... (cached) yes checking for string.h... (cached) yes checking sys/file.h usability... yes checking sys/file.h presence... yes checking for sys/file.h... yes checking sys/param.h usability... yes checking sys/param.h presence... yes checking for sys/param.h... yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for unistd.h... (cached) yes checking for an ANSI C-conforming const... yes checking for inline... inline checking whether time.h and sys/time.h may both be included... yes checking size of int... 4 checking size of float... 4 checking for struct flock... checking whether lstat correctly handles trailing slash... yes checking whether lstat accepts an empty string... no checking whether lstat correctly handles trailing slash... (cached) yes checking for stdlib.h... (cached) yes checking for unistd.h... (cached) yes checking for sys/param.h... (cached) yes checking for getpagesize... yes checking for working mmap... yes checking for working memcmp... yes checking for flock... yes checking for gettimeofday... yes checking for malloc... yes checking for memset... yes checking for munmap... yes checking for pow... yes checking for realpath... yes checking for strcasecmp... yes checking for strchr... yes checking for strdup... yes checking for strrchr... yes checking for strndup... yes checking for strtok_r... yes configure: creating ./config.status config.status: creating Makefile config.status: creating cli/Makefile config.status: creating etc/Makefile config.status: creating libscws/Makefile config.status: creating libscws/version.h config.status: creating config.h config.status: executing depfiles commands config.status: executing libtool commands
继续报错!!
[root@jxstar-dev scws-1.2.2]# make isntall make: *** 没有规则可以创建目标“isntall”。 停止。///////////////输错单词了install
再次执行
[root@jxstar-dev scws-1.2.2]# make install Making install in . make[1]: 进入目录“/home/scws-1.2.2” make[2]: 进入目录“/home/scws-1.2.2” make[2]: 对“install-exec-am”无需做任何事。 make[2]: 对“install-data-am”无需做任何事。 make[2]: 离开目录“/home/scws-1.2.2” make[1]: 离开目录“/home/scws-1.2.2” Making install in libscws make[1]: 进入目录“/home/scws-1.2.2/libscws” /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT charset.lo -MD -MP -MF .deps/charset.Tpo -c -o charset.lo charset.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT charset.lo -MD -MP -MF .deps/charset.Tpo -c charset.c -fPIC -DPIC -o .libs/charset.o mv -f .deps/charset.Tpo .deps/charset.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT crc32.lo -MD -MP -MF .deps/crc32.Tpo -c -o crc32.lo crc32.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT crc32.lo -MD -MP -MF .deps/crc32.Tpo -c crc32.c -fPIC -DPIC -o .libs/crc32.o mv -f .deps/crc32.Tpo .deps/crc32.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT pool.lo -MD -MP -MF .deps/pool.Tpo -c -o pool.lo pool.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT pool.lo -MD -MP -MF .deps/pool.Tpo -c pool.c -fPIC -DPIC -o .libs/pool.o mv -f .deps/pool.Tpo .deps/pool.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT scws.lo -MD -MP -MF .deps/scws.Tpo -c -o scws.lo scws.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT scws.lo -MD -MP -MF .deps/scws.Tpo -c scws.c -fPIC -DPIC -o .libs/scws.o mv -f .deps/scws.Tpo .deps/scws.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT xdict.lo -MD -MP -MF .deps/xdict.Tpo -c -o xdict.lo xdict.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT xdict.lo -MD -MP -MF .deps/xdict.Tpo -c xdict.c -fPIC -DPIC -o .libs/xdict.o mv -f .deps/xdict.Tpo .deps/xdict.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT darray.lo -MD -MP -MF .deps/darray.Tpo -c -o darray.lo darray.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT darray.lo -MD -MP -MF .deps/darray.Tpo -c darray.c -fPIC -DPIC -o .libs/darray.o mv -f .deps/darray.Tpo .deps/darray.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rule.lo -MD -MP -MF .deps/rule.Tpo -c -o rule.lo rule.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT rule.lo -MD -MP -MF .deps/rule.Tpo -c rule.c -fPIC -DPIC -o .libs/rule.o mv -f .deps/rule.Tpo .deps/rule.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT lock.lo -MD -MP -MF .deps/lock.Tpo -c -o lock.lo lock.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT lock.lo -MD -MP -MF .deps/lock.Tpo -c lock.c -fPIC -DPIC -o .libs/lock.o mv -f .deps/lock.Tpo .deps/lock.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT xdb.lo -MD -MP -MF .deps/xdb.Tpo -c -o xdb.lo xdb.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT xdb.lo -MD -MP -MF .deps/xdb.Tpo -c xdb.c -fPIC -DPIC -o .libs/xdb.o mv -f .deps/xdb.Tpo .deps/xdb.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT xtree.lo -MD -MP -MF .deps/xtree.Tpo -c -o xtree.lo xtree.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT xtree.lo -MD -MP -MF .deps/xtree.Tpo -c xtree.c -fPIC -DPIC -o .libs/xtree.o mv -f .deps/xtree.Tpo .deps/xtree.Plo /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=link gcc -g -O2 -no-undefined -version-info 2:0:1 -o libscws.la -rpath /usr/local/lib charset.lo crc32.lo pool.lo scws.lo xdict.lo darray.lo rule.lo lock.lo xdb.lo xtree.lo -lm libtool: link: gcc -shared .libs/charset.o .libs/crc32.o .libs/pool.o .libs/scws.o .libs/xdict.o .libs/darray.o .libs/rule.o .libs/lock.o .libs/xdb.o .libs/xtree.o -lm -Wl,-soname -Wl,libscws.so.1 -o .libs/libscws.so.1.1.0 libtool: link: (cd ".libs" && rm -f "libscws.so.1" && ln -s "libscws.so.1.1.0" "libscws.so.1") libtool: link: (cd ".libs" && rm -f "libscws.so" && ln -s "libscws.so.1.1.0" "libscws.so") libtool: link: ( cd ".libs" && rm -f "libscws.la" && ln -s "../libscws.la" "libscws.la" ) make[2]: 进入目录“/home/scws-1.2.2/libscws” test -z "/usr/local/lib" || /usr/bin/mkdir -p "/usr/local/lib" /bin/sh ../libtool --preserve-dup-deps --mode=install /usr/bin/install -c 'libscws.la' '/usr/local/lib/libscws.la' libtool: install: /usr/bin/install -c .libs/libscws.so.1.1.0 /usr/local/lib/libscws.so.1.1.0 libtool: install: (cd /usr/local/lib && { ln -s -f libscws.so.1.1.0 libscws.so.1 || { rm -f libscws.so.1 && ln -s libscws.so.1.1.0 libscws.so.1; }; }) libtool: install: (cd /usr/local/lib && { ln -s -f libscws.so.1.1.0 libscws.so || { rm -f libscws.so && ln -s libscws.so.1.1.0 libscws.so; }; }) libtool: install: /usr/bin/install -c .libs/libscws.lai /usr/local/lib/libscws.la libtool: finish: PATH="/usr/pgsql-10/bin:/usr/pgsql-10/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.8.0_221/bin:/root/bin:/sbin" ldconfig -n /usr/local/lib ---------------------------------------------------------------------- Libraries have been installed in: /usr/local/lib If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- test -z "/usr/local/include/scws" || /usr/bin/mkdir -p "/usr/local/include/scws" /usr/bin/install -c -m 644 'charset.h' '/usr/local/include/scws/charset.h' /usr/bin/install -c -m 644 'crc32.h' '/usr/local/include/scws/crc32.h' /usr/bin/install -c -m 644 'pool.h' '/usr/local/include/scws/pool.h' /usr/bin/install -c -m 644 'scws.h' '/usr/local/include/scws/scws.h' /usr/bin/install -c -m 644 'xdict.h' '/usr/local/include/scws/xdict.h' /usr/bin/install -c -m 644 'darray.h' '/usr/local/include/scws/darray.h' /usr/bin/install -c -m 644 'rule.h' '/usr/local/include/scws/rule.h' /usr/bin/install -c -m 644 'xdb.h' '/usr/local/include/scws/xdb.h' /usr/bin/install -c -m 644 'xtree.h' '/usr/local/include/scws/xtree.h' /usr/bin/install -c -m 644 'version.h' '/usr/local/include/scws/version.h' make[2]: 离开目录“/home/scws-1.2.2/libscws” make[1]: 离开目录“/home/scws-1.2.2/libscws” Making install in cli make[1]: 进入目录“/home/scws-1.2.2/cli” gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../libscws -g -O2 -MT scws_cmd.o -MD -MP -MF .deps/scws_cmd.Tpo -c -o scws_cmd.o scws_cmd.c mv -f .deps/scws_cmd.Tpo .deps/scws_cmd.Po /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=link gcc -g -O2 -o scws scws_cmd.o ../libscws/libscws.la -lm libtool: link: gcc -g -O2 -o .libs/scws scws_cmd.o ../libscws/.libs/libscws.so -lm -Wl,-rpath -Wl,/usr/local/lib gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../libscws -g -O2 -MT gen_dict.o -MD -MP -MF .deps/gen_dict.Tpo -c -o gen_dict.o gen_dict.c mv -f .deps/gen_dict.Tpo .deps/gen_dict.Po /bin/sh ../libtool --preserve-dup-deps --tag=CC --mode=link gcc -g -O2 -o scws-gen-dict gen_dict.o ../libscws/libscws.la -lm libtool: link: gcc -g -O2 -o .libs/scws-gen-dict gen_dict.o ../libscws/.libs/libscws.so -lm -Wl,-rpath -Wl,/usr/local/lib make[2]: 进入目录“/home/scws-1.2.2/cli” test -z "/usr/local/bin" || /usr/bin/mkdir -p "/usr/local/bin" /bin/sh ../libtool --preserve-dup-deps --mode=install /usr/bin/install -c 'scws' '/usr/local/bin/scws' libtool: install: /usr/bin/install -c .libs/scws /usr/local/bin/scws /bin/sh ../libtool --preserve-dup-deps --mode=install /usr/bin/install -c 'scws-gen-dict' '/usr/local/bin/scws-gen-dict' libtool: install: /usr/bin/install -c .libs/scws-gen-dict /usr/local/bin/scws-gen-dict make[2]: 对“install-data-am”无需做任何事。 make[2]: 离开目录“/home/scws-1.2.2/cli” make[1]: 离开目录“/home/scws-1.2.2/cli” Making install in etc make[1]: 进入目录“/home/scws-1.2.2/etc” make[2]: 进入目录“/home/scws-1.2.2/etc” test -z "/usr/local/etc" || /usr/bin/mkdir -p "/usr/local/etc" /usr/bin/install -c -m 644 'rules.ini' '/usr/local/etc/rules.ini' /usr/bin/install -c -m 644 'rules.utf8.ini' '/usr/local/etc/rules.utf8.ini' /usr/bin/install -c -m 644 'rules_cht.utf8.ini' '/usr/local/etc/rules_cht.utf8.ini' make[2]: 对“install-data-am”无需做任何事。 make[2]: 离开目录“/home/scws-1.2.2/etc” make[1]: 离开目录“/home/scws-1.2.2/etc”
是否安装成功
查看 scws 安装目录
[root@db1 scws-1.2.2]# ls /usr/local/include/scws/
charset.h crc32.h darray.h pool.h rule.h scws.h version.h xdb.h xdict.h xtree.h
6:安装zhparser
https://github.com/amutu/zhparser/archive/master.zip
[root@jxstar-dev home]# unzip zhparser-master.zip Archive: zhparser-master.zip 127a31b39db1b4ccc851f254683ced9a1fa837bd creating: zhparser-master/ inflating: zhparser-master/CHANGELOG inflating: zhparser-master/COPYRIGHT inflating: zhparser-master/META.json inflating: zhparser-master/Makefile inflating: zhparser-master/README.md inflating: zhparser-master/check.sh inflating: zhparser-master/dict.utf8.xdb inflating: zhparser-master/dict_extra.txt creating: zhparser-master/expected/ inflating: zhparser-master/expected/zhparser.out inflating: zhparser-master/rules.utf8.ini creating: zhparser-master/sql/ inflating: zhparser-master/sql/zhparser.sql inflating: zhparser-master/zhparser--1.0--2.0.sql inflating: zhparser-master/zhparser--1.0.sql inflating: zhparser-master/zhparser--2.0--2.1.sql inflating: zhparser-master/zhparser--2.0.sql inflating: zhparser-master/zhparser--2.1.sql inflating: zhparser-master/zhparser--unpackaged--1.0.sql inflating: zhparser-master/zhparser.c inflating: zhparser-master/zhparser.control inflating: zhparser-master/zhparser.h
开始报错:
[root@jxstar-dev home]# cd zhparser-master/ [root@jxstar-dev zhparser-master]# SCWS_HOME=/usr/local make&&make install make: pg_config:命令未找到 make: *** 无目标。 停止。
需要找到你pg_config 如果没有的话
yum install postgresql-devel
安装完毕后察看
/usr/bin/pg_config 可以查看到了
继续执行
[root@jxstar-dev zhparser-master]# SCWS_HOME=/usr/local make&&make install gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fPIC -I/usr/local/include/scws -I. -I. -I/usr/include/pgsql/server -I/usr/include/pgsql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o zhparser.o zhparser.c zhparser.c:15:27: 致命错误:utils/varlena.h:没有那个文件或目录 #include "utils/varlena.h" ^ 编译中断。 make: *** [zhparser.o] 错误 1
重新配置一下环境变量就好了,不知道为什么,可以评论解释或者加QQ820688215 交流
[root@jxstar-dev zhparser-master]# export PATH=/usr/pgsql-10/bin:$PATH [root@jxstar-dev zhparser-master]# pg_config=/usr/bin/pg_config make && make install //////////////或者执行 SCWS_HOME=/usr/local make&&make install 一样的 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I/usr/local/include/scws -I. -I./ -I/usr/pgsql-10/include/server -I/usr/pgsql-10/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o zhparser.o zhparser.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -shared -o zhparser.so zhparser.o -L/usr/pgsql-10/lib -Wl,--as-needed -L/usr/lib64 -Wl,--as-needed -Wl,-rpath,'/usr/pgsql-10/lib',--enable-new-dtags -lscws -L/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib /bin/mkdir -p '/usr/pgsql-10/lib' /bin/mkdir -p '/usr/pgsql-10/share/extension' /bin/mkdir -p '/usr/pgsql-10/share/extension' /bin/mkdir -p '/usr/pgsql-10/share/tsearch_data' /bin/install -c -m 755 zhparser.so '/usr/pgsql-10/lib/zhparser.so' /bin/install -c -m 644 .//zhparser.control '/usr/pgsql-10/share/extension/' /bin/install -c -m 644 .//zhparser--1.0.sql .//zhparser--unpackaged--1.0.sql .//zhparser--1.0--2.0.sql .//zhparser--2.0.sql .//zhparser--2.0--2.1.sql .//zhparser--2.1.sql '/usr/pgsql-10/share/extension/' /bin/install -c -m 644 .//dict.utf8.xdb .//rules.utf8.ini '/usr/pgsql-10/share/tsearch_data/'
到此安装完毕!
开始使用一下:
切换到postgres账户
创建extension
整理好这些文件后,就可以继续创建extension了。
切换到postgres账户
su - postgres
·3.2.2 安装扩展(每新建一个数据库都需要执行这一步;这里我直接使用的已有的一个测试数据库)
#查询已有的解析器
knowledge=# \dFp
[root@jxstar-dev zhparser-master]# su postgres bash-4.2$ psql -Upostgres psql (10.15) 输入 "help" 来获取帮助信息. postgres=# \dFp 文本剖析器列表 架构模式 | 名称 | 描述 ------------+---------+--------------------- pg_catalog | default | default word parser (1 行记录) postgres=#
postgres=# create extension zhparser; CREATE EXTENSION postgres=# \dFp 文本剖析器列表 架构模式 | 名称 | 描述 ------------+----------+--------------------- pg_catalog | default | default word parser public | zhparser | (2 行记录) postgres=# CREATE TEXT SEARCH CONFIGURATION testzhcfg (PARSER = zhparser); CREATE TEXT SEARCH CONFIGURATION postgres=# ALTER TEXT SEARCH CONFIGURATION testzhcfg ADD MAPPING FOR n,v,a,i,e,l WITH simple; ALTER TEXT SEARCH CONFIGURATION
创建名为testzhcfg的 可以在sql中使用的解析器
-- make test configuration using parser
//这样解析器就添加到当前数据库了。但是此时还是不能用,还需要创建使用zhparser作为解析器的全文搜索的配置,也就是需要给zhparser解析器
取一个在sql里面可以使用的名字。这里测试取的是(‘testzhcfg ’)。
CREATE TEXT SEARCH CONFIGURATION testzhcfg (PARSER = zhparser);
-- add token mapping
ALTER TEXT SEARCH CONFIGURATION testzhcfg ADD MAPPING FOR n,v,a,i,e,l WITH simple;
//#查询已有的解析器
knowledge=# \dFp
/////////////测试
-- ts_parse
SELECT * FROM ts_parse('zhparser', 'hello world! 2010年保障房建设在全国范围内获全面启动,从中央到地方纷纷加大 了保障房的建设和投入
力度 。2011年,保障房进入了更大规模的建设阶段。住房城乡建设部党组书记、部长姜伟新去年底在全国住房城乡建设工作会议上表示,要继续推
进保障性安居工程建设。');
-- test to_tsvector
SELECT to_tsvector('testzhcfg','“今年保障房新开工数量虽然有所下调,但实际的年度在建规模以及竣工规模会超以往年份,相对应的对资金的
需求也会创历>史纪录。”陈国强说。在他看来,与2011年相比,2012年的保障房建设在资金配套上的压力将更为严峻。');
-- test to_tsquery
SELECT to_tsquery('testzhcfg', '保障房资金压力');