reading notes for solr source code

solr source code
1 org.apache.solr.common 基本的类对象
2 org.apache.solr.common.params 存取参数的类,按照参数类型不同分为很多的类,
  (1) AnalysisParams 下有map,ModifiableSolrParams(LinkedHashMap),RequiredSolrParams,SolrQuery
  (2) CommonParams等
3 org.apache.solr.analysis
  (1) tokenizerFactory(BaseTokenizerFactory)可以按照字数(NGramTokenizerFactory)、正则、标签、关键字、
 字符、俄语、树结构(TrieTokenizerFactory)、空格
  (2) BaseCharFilterFactory
  (3) BaseTokenFilterFactory,按照语言种类、停词、元数据(payload)、语音(?DoubleMetaphoneFilterFactory)、
 带连字符的(HyphenatedWordsFilterFactory)、通配符(wildcard)、同义(synonym)
4 org.apache.solr.core
   (1)AbstractSolrEventListener含QuerySenderListener,newSearcher的warm在里面
   (2)core初始化相关 CoreContainer[n个CoreDescriptor];
   SolrCore 包含与搜索相关的
   设置/获取:ResponseHeader、Plugins、booleanQueryMaxClauseCount、getSearcher
   初始化/注册:DeletionPolicy、Listeners、searcher、IndexReader(witer)、Index、HighLighter
   (3)DirectoryFactory,IndexReaderFactory
   (4)索引commmit时间点的保留策略 IndexDeletionPolicyWrapper
   (5)JmxMonitoredMap extends ConcurrentHashMap(高并发多锁的hashmap)
   (6)RequestHandlers (can Read solrconfig.xml and register the appropriate handlers),
 包含LazyRequestHandlerWrapper,让lazyload的requestHandler在第一次调用该requestHandler时才初始化
   (7)SolrResourceLoader包含ClassLoader和getLines

5 org.apache.solr.handler和org.apache.solr.handler.admin
   (1)SnapShooter
   (2)ContentStreamLoader包含xml和csv两种update、delete、read数据的方式,and also can update handler which uses the JavaBin format
   (3)RequestHandlerBase
 SearchHandler(@dismax、相关度排序相关;
     @以组件形式添加各项功能参数及对参数的处理,eg.高亮、facet、mlt、query、stats、debug;
     @shard just the string like 'localhost:8080/complex/';
     @ShardResponse)
 AnalysisRequestHandlerBase(对request的xml进行处理,返回NamedList
        @analyzeTokenStream Analyzes the given TokenStream, collecting the Tokens it produces;
        @convertTokensToNamedLists;
        @AnalysisContext class)
 AnalysisRequestHandler(@processContent for Tokenizing doc;
       @readDoc)
   (4)CoreAdminHandler handleRequestBody为入口,针对各个core的状态进行加载core、重命名core、删除core等
   (5)MoreLikeThisHandler (@getMoreLikeThis mlt.like(lucene function)根据req获取相似度较高的文档集合添加到response中,传入一个doc,首先获取每一个字段的TermFreqVector(即tf),然后将其添加到TermFrequencies中;
  遍历TermFrequencies中所有的term,并取出其tf以及在所有指定字段中最大的df,根据df和当前索引文档数计算idf,然后计算每个term的score=tf*idf,并压入PriorityQueue,
  按照score从大到小取出一定数量的term(maxQueryTerm)进行组建构建一个BooleanQuery,用创建的query进行一次检索,取出得分最高的N篇文档即可。)
   (6)PluginInfoHandler 取出并呈现每个core下加载的QUERY HANDLERS、UPDATE HANDLERS、CACHE、HIGHLIGHTING 等信息
   (7)ReplicationHandler 提供api供slaves从master复制,设置复制的校验、复制前的的变量准备(eg.是否commit、optimize等),以及复制后的相关动作
      (@Adler32 包含校验的拷贝
      @getReplicationDetails showing statistics and progress information
      @FileStream class 带校验和的类)
   (8)ShowFileRequestHandler web方式读取conf文件(设置文件hidden可以控制文件不被访问)
   (9)SpellCheckerRequestHandler 根据空格分割字符串并按照SolrQueryRequest的extendedResults, cmd rebuild,accuracy, suggestionCount, restrictToField, and onlyMorePopular参数来
     选择性增加分割后word的相关信息,eg.词频、suggestion word等
   (10)SystemInfoHandler 包含core,jvm,lucene的systemInfo
   (11)ThreadDumpHandler 线程信息统计current,peak=,daemon
   (12)AdminHandlers 注册所有管理handlers(LukeRequestHandler、SystemInfoHandler、PluginInfoHandler、ThreadDumpHandler、ThreadDumpHandler、ShowFileRequestHandler)
6 org.apache.solr.handler.component
  (1)SearchComponent 基类,子类基本都包含多shards document的整合,即按照单机和分布式搜索分别使用process、distributeProcess
  (2)DebugComponent (dds debugging information to a request)
  (3)FacetComponent (@countFacets ;class DistribFieldFacet used for through each facet.field, adding results from this shard ;包含操作refine
    @facet_fields or facet_queries)
  (4)HighlightComponent (@usePhraseHighlighter 完全匹配才高亮 @highlightMultiTerm模糊匹配高亮 used with usePhraseHightlighter=false)
  (5)QueryComponent 查询类,涉及url参数的处理,获取查询结果集等
  (6)QueryElevationComponent 优先级提交类,elevate.xml中设置置前显示的以及排除的id doc
  (7)SpellCheckComponent  拼写检查、匹配 inform在tomcat启动时运行,加载spellcheck dic以及 convert都有默认的 (用途:你是不是要找那个关键词)
  (8)StatsComponent 根据字段类型获取facet stats
  (9)TermsComponent 实现自动提示功能,Return TermEnum information,rb.req.getSearcher().getReader().terms获取符合的term enum,涉及到term的词频等
  (10)TermVectorComponent  Return term vectors for the documents ,包含tv、tf、offsets、position、df、tf-idf等,TVMapper

7 org.apache.solr.highlight
  DefaultSolrHighlighter getPhraseHighlighter getSpanQueryScorer getFormatter getFragmenter
 简单的顺序
 TermQuery query = new TermQuery(new Term(“field”, “textFragment”));
 Scorer scorer = new QueryScorer(query);      //QueryScorer 是内置的计分器
 Highlighter highlighter = new Highlighter(scorer);
 TokenStream tokenStream =new SimpleAnalyzer().tokenStream(“field”,new StringReader(text));//是由分析器生成, 文本中高亮部分的起始和结束位置。
 System.out.println(highlighter.getBestFragment(tokenStream,text));  //利用Fragmenter将原始文本分割成多个片段

转自:http://www.cnblogs.com/ai464068163/archive/2012/03/06/2382209
2019-03-27 01:14

知识点

相关教程

更多

ActionEnglish Notes

ActionEnglish 11. sound engineer 录音师2. Rumor has it that* 人们都说…   据说…* Rumor has it that Andy is a nice guy.* Rumar has it that he is a rather difficult sound engineer.* 类似的还有:It is said that…* 类似的还有:

Web scraper open source

ByadminOnSeptember 10, 2012·Add Comment       What we know about open soucre web scrapping software? There are many open source scrapers out there. They’re free, but they do require a good deal

Open Source Search Engines in Java

Open Source Search Engines in Java Open Source Search Engines in Java Compass The Compass Framework is a first class open source Java framework, enabling the power of Search Engine semantics to your a

English,The Da Vinci Code,Chapter 1-3

CHAPTER 1 http://readanybooks.net/thrillers/TheDaVinciCode/28635.html   Robert Langdon awoke slowly. A telephone was ringing in the darkness - a tinny, unfamiliar ring. He fumbled for the bedside lamp

关于如何参与到开源项目中《How To Succeed In Open Source ( In Ways You Haven't Considered Yet )》

转自:http://gaslight.co/blog/how-to-succeed-in-open-source-in-ways-you-havent-considered-yet It’s Easy to Feel Entitled in the Open Source World  A while back, it was easy to think of open source projec

Solr总结

http://www.cnblogs.com/guozk/p/3498831.html Solr调研总结 1. Solr 是什么?  Solr它是一种开放源码的、基于 Lucene Java 的搜索服务器,易于加入到 Web 应用程序中。Solr 提供了层面搜索(就是统计)、命中醒目显示并且支持多种输出格式(包括XML/XSLT 和JSON等格式)。它易于安装和配置,而且附带了一个基于HTTP 的

Open source, Open mind

从csdn迁移博客到cnblog。为啥?因为这里的blog可以选择不发布...你懂的。 好吧,算是在这里的正式开博。欢迎大家来评。本博主要基调(不是基情)是技术。如果想看生活的,请移步qq空间或微信朋友圈 :) 写博就是抛砖引玉 写博就是养成总结的习惯 写博就是思想的开源。闭关锁国是没有出路的,open source才是主流(起码是今天公认的主流) 希望能认识到高手 转自:http://www.c

[solr]solr的安装

solr是什么?  翻译: SolrTMis the popular, blazing fast open source enterprise search platform from the Apache LuceneTMproject. Its major features include powerful full-text search, hit highlighting, faceted

[ solr扩展 ] Solr Spellchecker internals (now with tests!)

This story is part of the DZone Solr-Lucene Zone, which is brought to you in collaboration with the Solr/Lucene Community.Visit the Solr-Lucene Zonefor additional tutorials, videos, opinions, and othe

Apache Solr 的新特性

首先,我将简单复习一下 Solr,然后介绍如何获取和安装最新版本的 Solr 以及升级早期版本的要点。接着,我会介绍 Solr 1.3 的一些重要的增强功能,最后再看一下 Solr 的新特性。 复习:Solr 概念 从概念上,Solr 可以被分成四大块:        模式(schema.xml)  配置(solrconfig.xml)  索引  搜索    要理解模式,需要先理解 Lucene

Apache Solr questions

Apache Solr     My unanswered questions on Solr Unread articles Miscellaneous I was having a problem with using wildcard. It seems that the wildcard does not work when it is at the end of a word. If I

Solr调研总结

Solr调研总结 开发类型 全文检索相关开发 Solr版本 4.2 文件内容 本文介绍solr的功能使用及相关注意事项;主要包括以下内容:环境搭建及调试;两个核心配置文件介绍;维护索引;查询索引,和在查询中可以应用的高亮显示、拼写检查、搜索建议、分组统计、拼音检索等功能的使用方法。 版本 作者/修改人 日期 V1.0 gzk 2013-06-04   Solr 是什么?  Solr它是一种开放源码

solr 从零学习开始

开源企业搜索引擎SOLR的 应用教程 2010-10 目 录 1 概述... 4 1.1 企业搜索引擎方案选型... 4 1.2 Solr的特性... 4 1.2.1 Solr使用Lucene并且进行了扩展... 4 1.2.2 Schema(模式)... 5 1.2.3 查询... 5 1.2.4 核心... 5 1.2.5 缓存... 5 1.2.6 复制... 6 1.2.7 管理接口...

solr

Solr是一个独立的企业级搜索应用服务器,它对外提供类似于Web-service的API接口。 Solr是一个高性能,采用Java5开发,基于Lucene的全文搜索服务器。同时对其进行了扩展,提供了比Lucene更为丰富的查询语言,同时实现了可配置、可扩展并对查询性能进行了优化,并且提供了一个完善的功能管理界面,是一款非常优秀的全文搜索引擎。 Solr优点: (1)Solr 可以对几乎任何对象进行

solr定时增量索引

参考:官方文档,http://wiki.apache.org/solr/DataImportHandler#Scheduling googlecode 找到:https://code.google.com/p/solr-dataimport-scheduler/ 1.复制solr-4.2.11\solr-4.2.1\dist目录下solr-dataimporthandler-4.2.1.jar 和

最新教程

更多

java线程状态详解(6种)

java线程类为:java.lang.Thread,其实现java.lang.Runnable接口。 线程在运行过程中有6种状态,分别如下: NEW:初始状态,线程被构建,但是还没有调用start()方法 RUNNABLE:运行状态,Java线程将操作系统中的就绪和运行两种状态统称为“运行状态” BLOCK:阻塞状态,表示线程阻塞

redis从库只读设置-redis集群管理

默认情况下redis数据库充当slave角色时是只读的不能进行写操作,如果写入,会提示以下错误:READONLY You can't write against a read only slave.  127.0.0.1:6382> set k3 111  (error) READONLY You can't write against a read only slave. 如果你要开启从库

Netty环境配置

netty是一个java事件驱动的网络通信框架,也就是一个jar包,只要在项目里引用即可。

Netty基于流的传输处理

​在TCP/IP的基于流的传输中,接收的数据被存储到套接字接收缓冲器中。不幸的是,基于流的传输的缓冲器不是分组的队列,而是字节的队列。 这意味着,即使将两个消息作为两个独立的数据包发送,操作系统也不会将它们视为两个消息,而只是一组字节(有点悲剧)。 因此,不能保证读的是您在远程定入的行数据

Netty入门实例-使用POJO代替ByteBuf

使用TIME协议的客户端和服务器示例,让它们使用POJO来代替原来的ByteBuf。

Netty入门实例-时间服务器

Netty中服务器和客户端之间最大的和唯一的区别是使用了不同的Bootstrap和Channel实现

Netty入门实例-编写服务器端程序

channelRead()处理程序方法实现如下

Netty开发环境配置

最新版本的Netty 4.x和JDK 1.6及更高版本

电商平台数据库设计

电商平台数据库表设计:商品分类表、商品信息表、品牌表、商品属性表、商品属性扩展表、规格表、规格扩展表

HttpClient 上传文件

我们使用MultipartEntityBuilder创建一个HttpEntity。 当创建构建器时,添加一个二进制体 - 包含将要上传的文件以及一个文本正文。 接下来,使用RequestBuilder创建一个HTTP请求,并分配先前创建的HttpEntity。

MongoDB常用命令

查看当前使用的数据库    > db    test  切换数据库   > use foobar    switched to db foobar  插入文档    > post={"title":"领悟书生","content":"这是一个分享教程的网站","date":new

快速了解MongoDB【基本概念与体系结构】

什么是MongoDB MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era. MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。

windows系统安装MongoDB

安装 下载MongoDB的安装包:mongodb-win32-x86_64-2008plus-ssl-3.2.10-signed.msi,按照提示步骤安装即可。 安装完成后,软件会安装在C:\Program Files\MongoDB 目录中 我们要启动的服务程序就是C:\Program Files\MongoDB\Server\3.2\bin目录下的mongod.exe,为了方便我们每次启动,我

Spring boot整合MyBatis-Plus 之二:增删改查

基于上一篇springboot整合MyBatis-Plus之后,实现简单的增删改查 创建实体类 添加表注解TableName和主键注解TableId import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baom

分布式ID生成器【snowflake雪花算法】

基于snowflake雪花算法分布式ID生成器 snowflake雪花算法分布式ID生成器几大特点: 41bit的时间戳可以支持该算法使用到2082年 10bit的工作机器id可以支持1024台机器 序列号支持1毫秒产生4096个自增序列id 整体上按照时间自增排序 整个分布式系统内不会产生ID碰撞 每秒能够产生26万ID左右 Twitter的 Snowflake分布式ID生成器的JAVA实现方案