Xunsearch入门

mac2022-06-30  25

Xunsearch入门

简介: 开源免费、高性能、多功能、简单易用的专业全文检索技术方案。

1、Xunsearch安装: (1)官网(http://xunsearch.com)下载 wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2 (2)解压: tar -jxvf xunsearch-full-latest.tar.bz2 (3)进入目录(注意:这里的目录名字会根据最新的版本而不同) cd xunsearch-full-1.4.13 (4)安装(无需配置编译) sh setup.sh 说明: 1、安装过程会询问,需要指定安装目录(/usr/local/xunsearch) 2、首次安装可能需要几分钟,中间不出问题表示安装成功 (5)启动测试: cd /usr/local/xunsearch/bin ./xs-ctl.sh start 说明:也可以将/usr/local/xunsearch/bin目录添加到环境变量中。 (6)添加开机启动 在/etc/rc.local文件最后添加一句话: /usr/local/xunsearch/bin/xs-ctl.sh start 说明:会启动两个服务 1、索引服务(8383):负责索引的添加、删除和修改。 2、搜索服务(8384):负责提供搜索服务,即查询。2、体验demo项目 见手册。3、项目配置文件 基本说明: (1)项目配置是一个项目的核心灵魂,非常重要,通常保存为.ini文件, 通常存储在/usr/local/xunsearch/sdk/php/app/ (2)以分号开头的行表示注释,空行直接被忽略不起任何作用 (3)中括号包围的每个分区均为字段配置,字段个数根据项目的实际需求设定 (4)每个项目必须有并且只能有一个类型为ID的主键字段,ID字段值的字母不区分大小写 常规配置: 名称:project.name = xxx 字符集:project.default_charset = UTF-8 (默认) 索引服务端口:server.index = 8383 (默认) 搜索服务端口:server.search = 8384 (默认) 项目字段: 字段名: [字段名] 字段类型: type = xxx 字符类型:string,适用多数情况,也是默认值 数值型:numeric,包含整型和浮点型,仅当字段需要用于排序或区间检索时才设为该类型, 否则使用string类型即可。 日期型:date,形式为YYYYmmdd 这样固定的8字节,如果没有区间检索或排序不建议使用。 主键型:id,确保每条数据具备唯一值,是索引更新和删除的凭据, 每个搜索项目必须有且仅有一个id字段,该字段的值不区分大小写。 标题型:title,标题或名称字段,至多有一个该类型的字段。 内容型:body,主要内容字段,即本搜索项目中内容最长的字段, 至多只有一个该类型字段,本字段不支持字段检索。

PHP-SDK PHP-SDK的代码默认包含在服务端安装目录中,即$prefix/sdk/php。 对象: XS: 搜索项目总对象,所有相关操作均基于此对象及子方法。 XSDocument: 搜索结果或索引文档,包括一组字段及值,相当于SQL表中的一条记录。 XSIndex: 索引管理,通过XS对象的index属性取得。 XSSearch: 搜索功能,通过XS对象的search属性取得。 XSException: 异常类型,必须捕捉此异常以判断操作是否正确。基本使用: include '/usr/local/xunsearch/sdk/php/lib/XS.php'; try{ //创建搜索对象 $xs = new XS('demo');//demo为项目名称,配置文件是:$sdk/app/demo.ini。 //获取索引管理对象 $index = $xs->index; //获取搜索功能对象 $search = $xs->search; //创建索引文档 $data = [ 'pid' => 123, 'subject' => '测试文档标题', 'message' => '测试文档内容', 'chrono' => time() ]; $doc = new XSDocument($data); //添加索引 $index->add($doc); //更新索引 $index->update($doc); //同步索引 $index->flushIndex(); //清空索引 $index->clean(); //搜索 $res = $search->search('测试');//包含:测试 var_dump($res); $res = $search->search('测试 文档');//包含:测试 和 文档 var_dump($res); }catch(XSException $e){ echo $e->getTraceAsString(); }

使用sh setup.sh安装软件时,报以下错误:...configure: error: *** A compiler with support for C++11 language features is required.---ERROR: failed to configure xapian-core-scws, see 'setup.log' for more detail原因:gcc版本太低了。解决:(注意不要删除旧的gcc)wget ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/releases/gcc-8.3.0/gcc-8.3.0.tar.gztar -zxvf gcc-8.3.0.tar.gzcd gcc-8.3.0./configure --prefix=/usr/local/gcc-8.3.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib

 

checking whether we are using the GNU C++ compiler... nochecking whether g++ accepts -g... nochecking whether g++ accepts -static-libstdc++ -static-libgcc... nochecking for gnatbind... nochecking for gnatmake... nochecking whether compiler driver understands Ada... nochecking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2checking for objdir... .libschecking for the correct version of gmp.h... noconfigure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.Try the --with-gmp, --with-mpfr and/or --with-mpc options to specifytheir locations. Source code for these libraries can be found attheir respective hosting sites as well as atftp://gcc.gnu.org/pub/gcc/infrastructure/. See alsohttp://gcc.gnu.org/install/prerequisites.html for additional info. Ifyou obtained GMP, MPFR and/or MPC from a vendor distribution package,make sure that you have installed both the libraries and the headerfiles. They may be located in separate packages.

使用gcc -v查看当前版本。gcc 版本 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)

gcc-c++libtool

configure: error: configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.(1)安装GMP 1、下载:wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2 2、解压:tar -jxvf gmp-6.1.2.tar.bz2 3、进入目录:cd gmp-6.1.2 4、配置:./configure 5、编译:make 6、安装:make install(2)安装MPFR 1、下载:wget https://www.mpfr.org/mpfr-current/mpfr-4.0.2.tar.gz 2、解压:tar -zxvf mpfr-4.0.2.tar.gz 3、进入目录:cd mpfr-4.0.2 4、配置:./configure 5、编译:make 6、安装:make install(2)安装MPC 1、下载:wget http://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz 2、解压:tar -zxvf mpc-1.1.0.tar.gz 3、进入目录:cd mpc-1.1.0 4、配置:./configure 5、编译:make 6、安装:make install

GMP简介:gmp是一个任意精度算术的自由库,可以操作有符号整数、有理数和浮点数。除了运行GMP的机器中可用内存所暗示的精度外,没有实际限制。GMP有一套丰富的功能,这些功能有一个常规的接口。

MPFR简介:MPFR库是一个C库,用于正确舍入的多精度浮点计算。MPFR基于GMP多精度库。

yum install gcc-c++

安装gcc时,使用make命令时,报如下错误:...configure: error: C++ preprocessor "/lib/cpp" fails sanity check....问题的根源是缺少必要的C++库。(1)CentOS系统,运行命令: yum install glibc-headers yum install gcc-c++(2)Ubuntu系统中,运行命令: apt-get install build-essential apt-get install g++

安装gcc时,使用make命令时,报如下错误: error while loading shared libraries: libmpc.so.3: cannot open shared object file: No such file or directory解决办法:sudo vi /etc/ld.so.conf添加库路径 ./ (表示当前目录)

添加保存

然后

sudo ldconfig

查看gcc版本:gcc -v显示还是旧版本,4.4.7。使用which gcc查看命令的位置:结果显示:/usr/bin/gcc。解决: (1)卸载旧的gcc: yum remove gcc。 (2)配置新安装的gcc的位置到环境变量 vim /etc/profile    在文件末尾处增加以下代码,新安装的gcc路径    export PATH=$PATH:/usr/local/gcc-8.3.0/bin/    使修改的文件生效    source /etc/profile再次查看版本:已变成8.3.0.

启动xunsearch时:报错:/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found

wget http://ftp.de.debian.org/debian/pool/main/g/gcc-4.7/libstdc++6_4.7.2-5_i386.debar -x libstdc++6_4.7.2-5_i386.debtar -zxvf data.tar.gz

进入到gcc的目录中,我的gcc安装位置是:/usr/local/gcc-8.3.0。我的系统是64位的,所以进入到lib64目录下:cd /usr/local/gcc-8.3.0/lib64/查看libstdc++.so的最大数字。ls结果看到:libstdc++.so.6.0.25复制到/usr/lib64下(64位系统):cp libstdc++.so.6.0.25 /usr/lib64/进入到/usr/lib64下:查看:ls -l | grep libstdc++lrwxrwxrwx. 1 root root 19 3月 4 10:32 libstdc++.so.6 -> libstdc++.so.6.0.13-rwxr-xr-x. 1 root root 987096 6月 19 2018 libstdc++.so.6.0.13-rwxr-xr-x. 1 root root 12276491 3月 15 13:50 libstdc++.so.6.0.25删除旧的软连接:rm -f libstdc++.so.6建立新的软连接:ln -s libstdc++.so.6.0.25 libstdc++.so.6

strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX

 

      

转载于:https://www.cnblogs.com/gyfluck/p/11512042.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)