`
phpseyo
  • 浏览: 156840 次
  • 性别: Icon_minigender_1
  • 来自: 广西
社区版块
存档分类
最新评论

php连接coreseek

php 
阅读更多

<?php 

include_once 'sphinxapi.php';
$s = new SphinxClient();
$s->setServer("localhost", 9312);
$s->SetConnectTimeout ( 1 );//设置链接超时


/*
$s->AddQuery();//列表查询
$s->RunQueries ();//执行列表查询
$s->ResetFilters();//清除过滤条件
$s->BuildExcerpts($docs, $index, $words);//生成简要
$s->BuildKeywords($query, $index, $hits);//生成关键字
$s->GetLastError();//错误
$s->GetLastWarning();//警告
$s->FlushAttributes();//索引刷入硬盘
$s->IsConnectError();//链接错误
$s->ResetGroupBy();//重设分组

$s->SetFieldWeights(array('sub_title'=>1));//加权最小为1
$s->SetIDRange($min, $max);//ID范围
$s->SetIndexWeights(array('test1'=>1));//索引权重
$s->Status();//服务是否可用
$s->UpdateAttributes($index, $attrs, $values);//更新硬盘索引
*/
/*
参考文档:http://www.coreseek.cn/docs/coreseek_4.1-sphinx_2.0.1-beta.html#matching-modes
SPH_MATCH_ALL, matches all query words (default mode);
SPH_MATCH_ANY, matches any of the query words;
SPH_MATCH_PHRASE, matches query as a phrase, requiring perfect match;
SPH_MATCH_BOOLEAN, matches query as a boolean expression (see Section 5.2, “Boolean query syntax”);
SPH_MATCH_EXTENDED, matches query as an expression in Sphinx internal query language (see Section 5.3, “Extended query syntax”). As of 0.9.9, this has been superceded by SPH_MATCH_EXTENDED2, providing additional functionality and better performance. The ident is retained for legacy application code that will continue to be compatible once Sphinx and its components, including the API, are upgraded.
SPH_MATCH_EXTENDED2, matches query using the second version of the Extended matching mode.
SPH_MATCH_FULLSCAN, m
*/
$s->setMatchMode(SPH_MATCH_ANY);//匹配模式
$s->setMaxQueryTime(3);//查询超时
//$s->SetSelect ( $select );//设置返回的字段
/*
$cl->SetSelect ( "*, @weight+(user_karma+ln(pageviews))*0.1 AS myweight" );
$cl->SetSelect ( "exp_years, salary_gbp*{$gbp_usd_rate} AS salary_usd,
   IF(age>40,1,0) AS over40" );
$cl->SetSelect ( "*, AVG(price) AS avgprice" );
 */

/*
$cl->SetGroupBy ( "category", SPH_GROUPBY_ATTR, "@count desc" );
$cl->SetGroupDistinct ( "vendor" );
==
SELECT id, weight, all-attributes,
    COUNT(DISTINCT vendor) AS @distinct,
    COUNT(*) AS @count
FROM products
GROUP BY category
ORDER BY @count DESC
*/
//$s->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );//汇总
//$s->SetGroupDistinct ( $distinct );//设置不重复字段

$s->SetArrayResult ( true );//结果是否有ID

/*
    SPH_SORT_RELEVANCE mode, that sorts by relevance in descending order (best matches first);
    SPH_SORT_ATTR_DESC mode, that sorts by an attribute in descending order (bigger attribute values first);
    SPH_SORT_ATTR_ASC mode, that sorts by an attribute in ascending order (smaller attribute values first);
    SPH_SORT_TIME_SEGMENTS mode, that sorts by time segments (last hour/day/week/month) in descending order, and then by relevance in descending order;
    SPH_SORT_EXTENDED mode, that sorts by SQL-like combination of columns in ASC/DESC order;
    SPH_SORT_EXPR mode, that sorts by an arithmetic expression.
 */
//$s->SetSortMode ( SPH_SORT_EXTENDED, $sortby );//排序模式

/*
$s->SetOverride($attrname, $attrtype, $values);
$s->ResetOverrides();*/
/*
$s->SetRetries($count);//设置失败重试
$s->SetRankingMode($ranker);//设置排名模式 均适用于SPH_MATCH_EXTENDED2搜索

//第3个参数当为true时,相当于$attribute!=$value,默认值是false
$s->SetFilter ( 'target_type', $filtervals );//设置过滤,值列表
$s->SetFilterFloatRange($attribute, $min, $max);//浮动范围
$s->SetFilterRange($attribute, $min, $max);//指定范围
$s->SetGeoAnchor($attrlat, $attrlong, $lat, $long);
*/
//link
//$s->SetFilter ( 'target_type', array(1),true );


$s->SetLimits ( 0, 10 );//显示数量:开始 量 最大量 右偏移量
$result = $s->query("good","team");//查询


print_r($result);
 
分享到:
评论

相关推荐

    coreseek连接oracle的 cx_Oracle

    coreseek连接oracle数据库所需要的扩展包安装程序

    coreseek4.1.zip

    Coreseek 是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等...

    sphinx+coreseek安装配置

    详细说明sphinx+coreseek安装、配置、php很用

    Coreseek 4.1 参考手册

    Coreseek 4.1 参考手册,详细手册,网页文本

    coreseek4.1 for window

    coreseek4.1 window版本,sphinx 中文检索搜索引擎!

    站内全文搜索引擎 coreseek

    coreseek是在sphinx的基础上,增加了中文分词功能,换句话说,就是支持了中文。 Coreseek发布了3.2.14版本和4.1版本,其中的3.2.14版本是2010年发布的,它是基于Sphinx0.9.9搜索引擎的。而4.1版本是2011年发布的,...

    coreseek SPHINX 使用说明及详细介绍

    coreseek SPHINX 使用说明及详细介绍

    coreseek-3.2.14-win32

    基于sphinx的中文检索Sphinx如果需要对中文进行全文 检索,也得需要一些插件来补充。其中我知道的插件有 coreseek

    coreseek-4.1-win32

    coreseek被称为带有中文分词的sphinx,与 sphinx不同的是coreseek增加了一个带有中文分词的词库,本下载是coreseek-4.1-win32

    coreseek-4.1.tar.gz

    coreseek官网不知什么时候关了,无法下载安装包,这个亲测可用。 Linux版本coreseek-4.1-beta

    coreseek中日韩分词词库

    coreseek/sphinx分词词库txt版本(中日韩)

    coreseek3.1.14

    目录说明: csft-x.y.z:coreseek源代码 mmseg-i.j.k:mmseg源代码 testpack:测试配置和数据包

    coreseek-4.1

    sphinx coreseek 备用的coreseek,4.1版本。配合sphinx2,

    coreseek安装

    Coreseek 是一款可供企业使用的、基于Sphinx(可独立于Sphinx原始版本运行)中文全文检索/搜索软件,以GPLv2许可协议开源发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/...

    centos 6.5安装coreseek,亲测ok

    centos 6.5安装coreseek,亲测ok coreseek-3.2.14

    sphinx mmseg coreseek 搜狗 词库

    sphinx mmseg coreseek 搜狗 词库

    coreseek(sphinx + 中文分词)

    Coreseek 是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等...

    sphinx/coreseek权威手册中文版

    coreseek3.2版本(目前来说最稳定的coreseek版本)的权威中文手册,内部带配置和开发示例。

Global site tag (gtag.js) - Google Analytics