scrapy+sphinx搭建搜索引擎_第1页
scrapy+sphinx搭建搜索引擎_第2页
scrapy+sphinx搭建搜索引擎_第3页
scrapy+sphinx搭建搜索引擎_第4页
scrapy+sphinx搭建搜索引擎_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

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

文档简介

scrapy sphinx搭建搜索引擎 银平pkufranky 2010 06 07 Outline OverviewScrapy python爬虫框架Sphinx C 全文搜索引擎demo scrapy sphinx实现小说搜索引擎 Overview 搜索引擎 爬虫分类 搜索引擎通用搜索引擎垂直搜索引擎资源型垂直搜索引擎爬虫通用爬虫专用爬虫 Overview 搜索引擎 分词倒排索引http nlp stanford edu IR book html htmledition a first take at building an inverted index 1 html Scrapy python爬虫框架 ArchitectureBuilt inmiddlewaresExtensions从网页中提取数据 Architecture ComponentsScrapyEngineSchedulerDownloaderSpiderItemPipelineMiddlewaresEvent drivennetworking twisted Architecture Built inmiddlewares DownloadermiddlewaresDefaultHeadersMiddlewareHttpAuthMiddlewareHttpCacheMiddlewareRedirectMiddlewareRetryMiddlewareSpidermiddlewaresDepthMiddlewareRefererMiddlewareSchedulermiddlewaresDuplicatesFilterMiddleware Extensions 特性Scrapy启动时加载的普通class监听各种signal engine started item scraped item dropped Built inextensionsCoreStatsWebConsole 从网页中提取数据 CrawlSpider Rule Matcher callback使用XPath进行提取ScrapyshellParsley aselectorlanguage supersetofXPathandcss3 内存泄露 li main a href Sphinx C 全文搜索引擎 Sphinx特性Sphinx组件索引搜索SphinxSE mysql存储引擎 Sphinx特性 highindexingspeed upto10MB seconmodernCPUs highsearchspeed avgqueryisunder0 1secon2 4GBtextcollections highscalability upto100GBoftext upto100MdocumentsonasingleCPU providesgoodrelevancerankingthroughcombinationofphraseproximityrankingandstatistical BM25 ranking providesdistributedsearchingcapabilities providesdocumentexceprtsgeneration providessearchingfromwithinMySQLthroughpluggablestorageengine supportsboolean phrase andwordproximityqueries supportsmultiplefull textfieldsperdocument upto32bydefault supportsmultipleadditionalattributesperdocument ie groups timestamps etc supportsstopwords supportsbothsingle byteencodingsandUTF 8 supportsEnglishstemming Russianstemming andSoundexformorphology supportsMySQLnatively MyISAMandInnoDBtablesarebothsupported supportsPostgreSQLnatively Sphinx组件 indexer binary searchd binary search binary sphinxapi apilibrariesforPHP Python Perl Ruby spelldumpindextool 索引 数据源 数据库 xml 等等 表的每一行视为一篇文档 可在配置中指定哪些列需要进行索引属性 表的某些列可被指定为文档的属性 不被索引 但可用来做过滤和排序 索引 2 索引配置的片段sql query SELECTid title content author id forum id post dateFROMmy forum postssql attr uint author idsql attr uint forum idsql attr timestamp post date过滤和排序应用示例 onlysearchpostsbyauthorwhoseIDis123 cl SetFilter author id array 123 onlysearchpostsinsub forums1 3and7 cl SetFilter forum id array 1 3 7 sortfoundpostsbypostingdateindescendingorder cl SetSortMode SPH SORT ATTR DESC post date 搜索 匹配模式 匹配模式SPH MATCH ALLSPH MATCH ANYSPH MATCH PHRASESPH MATCH BOOLEANSPH MATCH EXTENDED2最灵活的SPH MATCH EXTENDED2hello worldhello world namehello introworld helloworld aaa bbb ccc helloworldfoo 10 theworldisawonderfulplace 3 helloworld title exampleprogram 5 bodypython php perl code 搜索 排序模式 SPH SORT RELEVANCESPH SORT EXTENDED weightDESC priceASC idDESCSPH SORT EXPR cl SetSortMode SPH SORT EXPR weight user karma ln pageviews 0 1 搜索 分布式搜索 横向划分数据 分别进行索引在主searchd上配置分布式索引主searchd发送请求到各个从searchd 合并返回的结果 并最终返回cluster中的每个searchd都可作为主searchd 进行负载均衡 搜索 SphinxQL 使用sql语法进行搜索 searchd实现了mysql的网络协议可将searchd当做mysql服务器使用 通过mysqlclient连接SELECT weight 10 docboostASskeyFROMexampleORDERBYskeSELECT FROMtest1WHEREMATCH testdoc 3 SELECT FROMtestWHEREMATCH titlehello bodyworld OPTIONranker bm25 max matches 3000 SphinxSE mysql存储引擎 特点类似InnoDB MyISAM 需要编译进mysql本身不存储数据 而是与searchd通信来获取数据优点任何语言都可使用 而naiveapi只支持几种语言当搜索结果需要在mysql端进一步处理时 效率更高 JOIN mysql likefiltering Sphinxvs xapian Sphinxsearchd提供搜索服务不用自己实现ind

温馨提示

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

评论

0/150

提交评论