搜索服务器xunsearch实现
安装方法:
centos 6.6 64位
histroy:
12 cd /srv/
13 wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2
14 tar -xjf xunsearch-full-latest.tar.bz2
15 cd cd xunsearch-full-1.3.0/
16 sh setup.sh
17 cd xunsearch-full-1.4.9/
18 sh setup.sh
19 +=================================================+
20 | Installation completed successfully, Thanks you |
21 | 安装成功,感谢选择和使用 xunsearch |
22 +-------------------------------------------------+
23 | 说明和注意事项: |
24 | 1. 开启/重新开启 xunsearch 服务程序,命令如下: |
25 | /home/bcenter/xunsearch/bin/xs-ctl.sh restart
26 | 强烈建议将此命令写入服务器开机脚本中 |
27 | |
28 | 2. 所有的索引数据将被保存在下面这个目录中: |
29 | /home/bcenter/xunsearch/data
30 | 如需要转移到其它目录,请使用软链接。 |
31 | |
32 | 3. 您现在就可以在我们提供的开发包(SDK)基础上 |
33 | 开发您自己的搜索了。 |
34 | 目前只支持 PHP 语言,参见下面文档: |
35 | /home/bcenter/xunsearch/sdk/php/README
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
date_default_timezone_set('prc');
$prefix = "/home/bcenter/xunsearch"; //xunsearch安装的位置
require_once "$prefix/sdk/php/lib/XS.php";
$xs = new XS('demo'); // 自动使用 $prefix/sdk/php/app/demo.ini 作项目配置文件
$xs = new XS('/home/bcenter/xunsearch/sdk/php/app/demo.ini'); // 使用 /path/to/demo.ini
$index = $xs->index; // 获取 索引对象
/*
#
$data = array(
'pid' => 234, // 此字段为主键,是进行文档替换的唯一标识
'subject' => '测试文档的标题',
'message' => '测试文档的内容部分',
'chrono' => time()
);
// 创建文档对象
$doc = new XSDocument;
$doc->setFields($data);
// 更新到索引数据库中
$index->update($doc);
*/
$docs = $xs->search->search('测试');
foreach ($docs as $doc)
{
// 其中常用魔术方法:percent() 表示匹配度百分比, rank() 表示匹配结果序号
echo $doc->rank() . '. ' . $doc->subject . " [" . $doc->percent() . "%] - ";
echo $doc->pid . "\n" . $doc->message . "\n";
}
?>
=====
屏幕输出:
1. 测试文档的标题 [100%] - 234 测试文档的内容部分
\home\bcenter\xunsearch\sdk\php\app\demo.ini
code:
project.name = demo
project.default_charset = utf-8
server.index = 127.0.0.1:8383 #先配置地址,不然运行php报错。
server.search = 127.0.0.1:8384
[pid]
type = id
[subject]
type = title
[message]
type = body
[chrono]
type = numeric
说明: 此练习是简单使用demo。链接见:
http://www.xunsearch.com/doc/php/guide/start.changelog
搜索服务器xunsearch实现的更多相关文章
- Spring Data Solr教程(翻译) 开源的搜索服务器
Solr是一个使用开源的搜索服务器,它采用Lucene Core的索引和搜索功能构建,它可以用于几乎所有的编程语言实现可扩展的搜索引擎. Solr的虽然有很多优点,建立开发环境是不是其中之一.此博客条 ...
- Apache Solr采用Java开发、基于Lucene的全文搜索服务器
http://docs.spring.io/spring-data/solr/ 首先介绍一下solr: Apache Solr (读音: SOLer) 是一个开源.高性能.采用Java开发.基于Luc ...
- 使用 Solr 构建企业级搜索服务器
最近因项目需要一个全文搜索引擎服务, 在考察了Lucene及Solr后,我们选择了Solr. 本文简要记录了基于Solr搭建一个企业搜索服务器的过程.网上的资料太多千篇一律,也可能版本不同,总之在参照 ...
- 搜索服务器Elasticsearch
基本 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticsearch是用Java开发的,并作为Ap ...
- 搜索服务solr 一二事(1) - solr-5.5 使用自带Jetty或者tomcat 搭建单机版搜索服务器
solr,什么是solr,就是你要吃的东西“馊了”,不能吃了,out of date~ 嘛...开个玩笑,发音就是‘搜了’,专门用于搜索的一个开源框架,lunce就不说了,不好用,麻烦 来讲讲solr ...
- Ubuntu搭建solr搜索服务器
参考:http://blog.csdn.net/makang110/article/details/50971705 一:搭建solr服务器 1:安装jdk1.7,并配置环境变量 2:下载tomcat ...
- Spring Data 整合 ElasticSearch搜索服务器
一.基于 maven 导入坐标(pom.xml文件) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi ...
- solr--搭建全文搜索服务器
1.下载http://www-eu.apache.org/dist/lucene/solr/6.5.0/ 2.新建: 云模式 3.打开浏览器: 简单的中文分词,暂时是一个一个的分词:
- 记录XunSearch(讯搜)的使用教程步骤(CentOS7下)
一.安装编译工具 yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel ...
随机推荐
- Linux文件管理常用命令
1.目录管理 [ls.cd.pwd.mkdir.rmdir.tree] tree:list contents of directories in a tree-like format. 2.文件管理 ...
- Remove Element,Remove Duplicates from Sorted Array,Remove Duplicates from Sorted Array II
以下三个问题的典型的两个指针处理数组的问题,一个指针用于遍历,一个指针用于指向当前处理到位置 一:Remove Element Given an array and a value, remove a ...
- php中的一些编程例子
#一到一百不能被三整除的数 for($i=1;$i<=100;$i++){ if($i%3 != 0){ $arr[] = $i; }} var_dump($arr); #水仙花数for($i= ...
- Android 圆形背景shape定义
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http: ...
- digital root问题
问题阐述会是这样的: Given a non-negative integer num, repeatedly add all its digits until the result has only ...
- linux第七章《档案与目录管理》重点回顾
- iOS UITableViewCell透明度 和 cell文字居中
1.创建UITableViewCell时,的模式用UITableViewCellStyleValue1时,透明度直接将UITableView的透明度设置以下就搞定拉,但是文字居中难以实现. 2.创建U ...
- POJ 1556 计算几何+最短路
代码1: #include<iostream> #include<stdio.h> #include<string> #include<string.h> ...
- java设计模式之——代理模式
1,什么是代理模式? 代理模式的作用是:为其他对象提供一种代理以控制对这个对象的访问. 2,策略模式有什么好处? 在某些情况下,一个客户不想或者不能直接引用另一个对象,而代理对象可以在客户端和目标对象 ...
- android混淆打包配置(忽略第三方jar)
在project.properties里加上 proguard.config=proguard.cfg proguard.cfg 配置如下: -optimizationpasses 5-dontu ...