Contents
1. Source Repository来源库
1. Solr Plugins
1. Customizing the Path Prefix Solr Intercepts
Hacking On Solr
Source Repository
TheSolr website contains Information about the Lucene/Solr Source Code SVN Repository
Solr的网站包含了Lucene/ Solr的源代码SVN库的信息
Thereare currently two active development branches: "branches/branch_4x/"which all 4.x releases are derived from, and "trunk" which will be Solr5.0. There are nightly builds for both.
目前有两个活动开发的分支:所有的4.x版本均来自“branches/branch_4x/”,“trunk”将会是Solr5.0。两个都有每夜版。
Hacking With Solr
Solr Plugins
The first thing to know if you are interested in hackingand customizing Solr, is that you may not need to customize the source at all.Solr has a fairly extensive number of Plugin Hooks that allow you to add custom functionality for a varietyof purposes by developing against some simple APIs, and then use your pluginsby placing your jar in a special "lib" directory and referring tothem by name in your configuration file.
首先要知道的是,如果你有兴趣破解和定制Solr,你可能并不需要定制源代码。Solr中有相当广泛的插件钩子,允许通过开发一些简单的API添加多种用途的自定义功能,将你的jar放到一个特殊的lib目录,通过你的配置文件中用名字来指代他们,来使用你的插件。
Customizing the War
Solr3.4 Note thatthe ant build.xml files changed in Solr 3.4+, so these instructions would needto be altered for earlier versions.
请注意Solr3.4的ant build.xml文件和Solr3.4+的有所不同,所以这些指令需要在早期版本中改变。
If you want to know how to add a custom plugin and letthe plugin replace the web.xml. Create your plugin similar the existing pluginsin the contrib directory. Create abuild.xml file and add this to the build.xml file. You will need to change thebuild.xml to fit your needs but this build.xml is showing you post-compileexecutions. What it is supposed to do is to replace the web.xml filewith a custom-web.xml file and to place a compiled jar file from the plugin into the lib directory so that solr will include it in the solr.war file.
如果你想知道如何添加一个自定义插件并让插件替换web.xml。在contrib目录里创建一个和现有插件类似的插件。创建一个build.xml文件并添加到build.xml文件中。你需要修改build.xml来满足您的需求,但这个build.xml文件会显示你编译后的效果。什么是应该做的,是要用一个自定义的web.xml文件来取代web.xml文件,并把插件中编译后的jar文件放到lib目录,以便Solr可以将它包括在solr.war文件里。
<?xml version="1.0"?>
<projectname="solr-customplugin" default="default">
<propertyname="contrib.has.webapp" value="true" />
<importfile="../contrib-build.xml"/>
<!-- Add the compiled jar toour war file -->
<targetname="add-to-war">
<echo message="CUSTOM:Cleaning ${common-solr.dir}/lib/${fullnamever}.jar from the build " />
<deletefailοnerrοr="false"file="${common-solr.dir}/lib/${fullnamever}.jar" />
<echo message="CUSTOM:Copying ${common-solr.dir}/dist/${fullnamever}.jar to ${common-solr.dir}/lib"/>
<copyfile="${common-solr.dir}/dist/${fullnamever}.jar"todir="${common-solr.dir}/lib"/>
<deletefailοnerrοr="false"file="${common-solr.dir}/webapp/web/WEB-INF/web.xml" />
<copyfile="web-custom.xml" tofile="${common-solr.dir}/webapp/web/WEB-INF/web.xml"/>
</target>
<description>Build filefor CUSTOM Search specifics</description>
<!-- Add this whenever wewant to build the example -->
<targetname="example" depends="common-solr.dist"/>
</project>
Source : http://www.nickveenhof.be/blog/adding-custom-plugin-solr
web.xml Hacks
Some behavior of Solr can be modified just by changingthe web.xml
一些solr行为可以通过修改web.xml来改进。
Customizing the Path Prefix Solr Intercepts
If you are wiring Solr into a larger web applicationwhich controls the web context root, you will probably want to mount Solrunder a path prefix (app.war with /app/solr mounted into it, for example). Youwill need to specify a prefix init-param for the SolrDispatchFilter to do this.See the comments in the web.xml for details.
如果你将Solr架设到一个可以控制web context root的较大的web应用中,你可能会想在某个路径的前缀下安装Solr(例如带有app/solr的app.war)。你需要为SolrDispatchFilter指定前缀初始化参数中来做到这一点。详见web.xml中的注释。
Hardcoding Solr Home
The Solr Home can be hardcoded using JNDI
Solr Home可以使用JNDI硬编码
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>/put/your/solr/home/here</env-entry-value>
</env-entry>
Embedding Solr
In addition to using Solr as a web based application, theSolrJ API provides the ability to embedded the core Solr functionality into anyJava application usingEmbeddedSolrServer.
除了将Solr作为一个基于Web的应用程序使用之外,SolrJ API可以提供嵌入式核心Solr的功能集成到任何使用EmbeddedSolrServer的Java应用程序中。