nzinfo_ Coreseek-Sphinx 全文检索实践指南 PHP.ppt_第1页
nzinfo_ Coreseek-Sphinx 全文检索实践指南 PHP.ppt_第2页
nzinfo_ Coreseek-Sphinx 全文检索实践指南 PHP.ppt_第3页
nzinfo_ Coreseek-Sphinx 全文检索实践指南 PHP.ppt_第4页
nzinfo_ Coreseek-Sphinx 全文检索实践指南 PHP.ppt_第5页
已阅读5页,还剩37页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Coreseek Sphinx全文检索实践指南 李沫南2010 12 19 Whatwillbecovered AIntroductionofFulltextSearchBriefCompareofOpenSourceFTEnginesWhychooseSphinxWhousingSphinx 全文检索VS数据库检索 SELECT FROMdocumentsWHEREtitlelike test CPU100 30秒内只能进行一次查询 没有找到记录 如何解决 为了提升数据库的性能 在某些字段上建索引答案 在全文字段上加索引 数据库的全文索引 全文索引字段 数据库的标配功能MySQL PostgreqSQLSQLServer Oracle问题 影响记录的存取性能非标准的检索语法切分规则 排序规则 Tooslowwhileindexingreal worlddataset NoMagic 倒排索引 比普通数据库检索快几倍 几百倍的性能提升预读取 预切分想想新华字典倒排索引 反向索引 Term1 Doc1 pos1 pos2 pos Doc2 Doc3 正向索引Doc1 Term1 pos1 pos2 pos 全文检索技术的宗教传统 线上的查经工具 倒排索引历史 主后1230年 根据拉丁文圣经编制主持者HugodeSanctoCharo雨果参与着500多人主后1550年 第一部英文的词索引编者JohnMarbeck计算机出现后 计算机辅助编制索引70 80年代 MAT程序族 圣经倒排索引的假设 所有词语具有一样的重要性不考虑词语出现的先后顺序分章 分节不考虑排序 按照出现的先后顺序排序 全文检索的最简化模型 WordOfBag把文档作为一个口袋Term是口袋中的元素 假设 元素之间地位平等顺序无关独立分布Boolean检索非此即彼的二元世界观aANDb aORb aNOTb 全文检索向量空间模型 把文档视为一个向量DocumentVector term1 term2 termN QueryVector term1 term2 全文检索概率模型 TF IDF算法OkapiBM25 BM BestMatch PhraseRanking 向量空间模型的优缺点 优点考虑到了Term出现的频率相对更好的相关度排序缺点不适合处理超长文件或者同一集合上 文件长度的尺寸差距很大检索的Term必须完全匹配不考虑语用 同义词 近义词 CJK短语支持 其他的模型 开源检索系统的对比分析 开源传万世 因有我参与常见开源的全文检索系统一览Lucene Nutch SolrAPLSphinx CoreseekGPL 商业授权XapianGPLLemur 支持LanguageModel BSD非主流ZettairTerrier 如何评价检索系统 检索精度 F Score 查全率 查准率 相关度 可以处理的数据规模 系统架构使用的检索模型 概率 向量空间 语言 特性 字段检索 自定义排序 属性过滤正向索引 反向索引 分布式支持接口的丰富程度业务的其他需要没有圣杯 WhyIchooseSphinx TerabyteIndex良好的文档支持与LAMP软件栈紧密集成唯一可选的C C 检索系统 2006 Lucene不适用于复杂检索 2006 IhateJava Sphinx Coreseek 特性介绍 1 高速建立索引 丰富的查询表达式 ANDORNOT句子段落模糊 字段 多种结果后处理机制 GroupBy OrderBy CustomWeighting 在生产环境中 千万篇文档 Tb级索引 数千查询 秒 Sphinx Coreseek 特性介绍 2 easyintegrationwithSQLandXMLdatasources andSphinxAPI SphinxQL orSphinxSEsearchinterfaces easyscalingwithdistributedsearches PythondatasourceadapterlayerBuild inChineseTokenizer Coreseek Sphinx VSLucene Coreseek Sphinx 开箱即用的产品 LAMP 支持各种数据来源 viaPythonSource 内置中文分词 商业支持LuceneJava人力成本低库结构设计 修改容易第三方工具 分布式 SphinxVSLucene FasterIndexingFaster morerelevantsearchingSQLstylequeriesWecandoJava butdon trequireaJavastack RT IndexVS InmemoryIndex Sphinx优势 BM25RankerphrasebaserankingBoosts sub phrasematchesPerfectmatchisguaranteedtoberanked 1内置Grouping 分布式支持 Sphinx限制 20G Per singleIndexCRC64WordIDFieldMask Only24FieldSupportedAllattributesinmemory PoorwindowssupportNoinnercachesupportHardtohandlemorethan3Tdata 吹牛时间 酒精考验的Sphinx B3KW文档 1M query 20 30GBdocs 50M query day国内的实施ChinaUnixBlogbus51CTO金融街BBS ManysiteIneverseen duetoOpenSource 某档案馆检索 Tb AShortBreak Indexer的流程 读取数据从数据库中读取用户主动Push RTIndex Tokenizer西文 词根 缩写的解读 CJK 切分 建立 倒排 索引局部倒排合并 CheckTheIndex UseSearchutilitytoqueryaindexincliUseindex tooltodumpaindex 索引文件格式 简介 spi Dictionary thecompletelistofwordid s spa Attributes onlyifdocinfo extern spd Documentlists foreachkeyword spp Hitlists foreachkeyword spm MVAvalues HowSearchingworks ForeachlocalindexBuildalistofcandidates documentsthatsatisfythefull textquery Filter theanalogyisWHERE Rank computethedocuments relevancevalues Sort theanalogyisORDERBY Group theanalogyisGROUPBY Mergetheresultsfromallthelocalindexes SQL数据源 处理流程 ConnectedtothedatabasePre query initialsetupMainquery feeddataPost query cleanupDisconnectedSorting Connecttopreformpost index disconnected MMSeg OtherTokenizer 1 MMSeg的历史从CRFSeg简化而来早期阶段 内置集成现在 外挂 仅处理中文未来 全外挂对配置的增加 index节 charset dictpathcharset type zh cn utf 8charset debug MMSeg OtherTokenizer 2 字段设置prefix fieldsprefix fields url domaininfix fieldsPhrase设置phrase boundaryphrase boundary U 2026phrase boundary step 构建索引 Indexer 执行indexer configcsft conf allindexer configcsft conf theindexname indexer configcsft conf theindexname rotate定期重建Crontab TaskKit Python Nowwehavetheindex Searchd 推荐的连接方式SphinxAPIPHPPythonRubyPerlSphinxQLMySQL兼容客户端RestfulAPIByCoreseek indeveloping DemoCode PHPClientSide CreateaclientobjectSetuptheoptionsFirethequery SetMatchMode SPH MATCH PHRASE cl SetSortMode SPH SORT EXTENDED pricedesc res cl Query ipodnano products var dump res DemoResult PHPClientSide MatcheswillalwayshavedocumentID weightMatchescanalsohavenumericattributes Nostringattributesyet pullthemfromMySQL print r result matches 0 Array id 123 weight 101421 attrs Array group id 12345678901 added 1207261463 DBVs SphinxWhotakethejob SQLquerypartsthatcanbemovedtoSphinxFiltering WHEREvs SetFilter orfakekeywordSorting ORDERBYvs SetSortMode Grouping GROUPBYvs SetGroupBy Upto100 x improvementvs na ve approachRuleofthumb moveeverythingyoucanfromMySQLtoSphinx SphinxSearchingpipeline Search WHERE rank ORDER GROUP Cheap booleansearchingfirstThenfilters WHEREclause Then expensive relevancerankingThensorting ORDERBYclause and orgrouping GROUPBYclause GroupBy 1 SetGroupBySetGroupDistinct GroupBy SetGroupBy 2 functionSetGroupBy attribute func groupsort groupdesc attribute readwhichattribute func 加工 attributeSPH GROUPBY DAY WEEK MONTH YEAR SPH GROUPBY ATTR groupsort Sortthegroupingorder GroupBy SetGroupDistinct 3 functionSetGroupDistinct attribute cl SetGroupBy category SPH GROUPBY ATTR countdesc cl SetGroupDistinct vendor SELECTid weight all attributes COUNT DISTINCTvendor AS distinct COUNT AS countFROMproductsGROUPBYcategoryORDERBY countDESC 结果高亮 BuildExcerpts

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论