Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change 
notification.

The "SolrPlugins" page has been changed by FrankWesemann.
http://wiki.apache.org/solr/SolrPlugins?action=diff&rev1=35&rev2=36

--------------------------------------------------

  = Solr Plugins =
- 
- Solr allows you to load custom code to perform a variety of tasks within Solr 
-- from custom Request Handlers to process your searches, to custom Analyzers 
and Token Filters for your text field, even custom Field Types.
+ Solr allows you to load custom code to perform a variety of tasks within Solr 
-- from custom Request Handlers to process your searches, to custom Analyzers 
and Token Filters for your text field, even custom Field Types. 
<<TableOfContents>>
- <<TableOfContents>>
  
  = How to Load Plugins =
- 
- Plugin code can be loaded into Solr by putting Jars containing your classes 
in a `lib` directory in your Solr Home directory prior to starting your servlet 
container.  In the example program, the location is example/solr/lib.  ''This 
directory does not exist in the distribution'', so you would need to do `mkdir` 
for the first time. 
+ Plugin code can be loaded into Solr by putting Jars containing your classes 
in a `lib` directory in your Solr Home directory prior to starting your servlet 
container.  In the example program, the location is example/solr/lib.  ''This 
directory does not exist in the distribution'', so you would need to do `mkdir` 
for the first time.
  
  This feature for loading plugins uses a custom Class Loader.  It has been 
tested with a variety of Servlet Containers, but given the multitudes of 
servlet containers available in the wild it may not always work with ''every'' 
servlet container.
  
  == The Old Way ==
- 
  Another method that works consistently on any servlet container is to:
+ 
-    1. unpack the solr.war
+  1. unpack the solr.war
-    1. add a jar containing your custom classes to the `WEB-INF/lib` directory
+  1. add a jar containing your custom classes to the `WEB-INF/lib` directory
-    1. repack your new, customized, solr.war and use it.
+  1. repack your new, customized, solr.war and use it.
  
  = Classes that are 'Pluggable' =
- 
  The following is a complete list of every API that can be treated as a plugin 
in Solr, with information on how to use that configure your Solr instance to 
use an instance of that class.
  
  == Request Processing ==
- 
  === SolrRequestHandler ===
- 
  Instances of 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/request/SolrRequestHandler.html|SolrRequestHandler]]
 define the logic that is executed for any request.  Multiple handlers 
(including multiple instances of the same !SolrRequestHandler class with 
different configurations) can be specified in your 
[[SolrConfigXml|solrconfig.xml]]...
  
  {{{
@@ -41, +35 @@

       <int name="someConfigValue">42</int>
    </requestHandler>
  }}}
- 
  for more info, see: SolrRequestHandler
  
  ==== SearchComponent ====
@@ -52, +45 @@

  for more info, see: SearchComponent
  
  ==== QParserPlugin ====
- 
  /!\ :TODO: /!\ NEED DOCS
  
  
[[http://lucene.apache.org/solr/api/org/apache/solr/search/QParserPlugin.html|QParserPlugin]]
 can be used to define customized user query processing instances of 
[[http://lucene.apache.org/solr/api/org/apache/solr/search/QParser.html|QParser]]
 .
  
- First, implement a subclass of 
[[http://lucene.apache.org/solr/api/org/apache/solr/search/QParserPlugin.html|QParserPlugin]]
 and register it
+ First, implement a subclass of 
[[http://lucene.apache.org/solr/api/org/apache/solr/search/QParserPlugin.html|QParserPlugin]]
 and register it in [[SolrConfigXml|solrconfig.xml]] like this:
- in [[SolrConfigXml|solrconfig.xml]] like this:
  
  {{{
    <queryParser name="myqueryparser" class="my.package.MyQueryParserPlugin" />
  }}}
- 
  Having done this, you can choose to use your query parser on a one-time basis 
using the defType query parameter, like this:
+ 
  {{{
  http://mysolrmachine:8983/solr/select/?defType=myqueryparser&q=hi
  }}}
- 
  You can also specify your query parser as part of the q parameter, like this:
+ 
  {{{
  http://mysolrmachine:8983/solr/select/?&q={!myqueryparser}hi
  }}}
- 
  For more permanent use, you will likely want to define a separate 
SolrRequestHandler for your parser, like this:
  
  {{{
@@ -81, +71 @@

      <lst name="defaults">
       <str name="defType">myqueryparser</str>
       ...
- 
  }}}
- 
- 
- 
  ==== ValueSourceParser ====
  Use this to plugin your own custom functions see FunctionQuery.
  
  register in solrconfig.xml directly under the <config> tag
+ 
  {{{
  <valueSourceParser name="myfunc" class="com.mycompany.MyValueSourceParser" />
  }}}
- 
  The class must implement 
[[http://lucene.apache.org/solr/api/org/apache/solr/search/ValueSourceParser.html|org.apache.solr.search.ValueSourceParser]]
  
- 
  === Highlighting ===
- 
  /!\ :TODO: /!\ NEED DOCS
  
  ==== SolrFragmenter ====
- 
  /!\ :TODO: /!\ NEED DOCS
  
  ==== SolrFormatter ====
- 
  /!\ :TODO: /!\ NEED DOCS
  
  === UpdateRequestProcessorFactory ===
- 
  /!\ :TODO: /!\ NEED DOCS
  
- See [[UpdateRequestProcessor]]
+ See UpdateRequestProcessor
  
  === QueryResponseWriter ===
- 
  Instances of 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/request/QueryResponseWriter.html|QueryResponseWriter]]
 define the formatting used to output the results of a request.  Multiple 
writers (including multiple instances of the same !QueryResponseWriter class 
with different configurations) can be specified in your 
[[SolrConfigXml|solrconfig.xml]]...
  
  {{{
@@ -125, +105 @@

    <queryResponseWriter name="woz" 
class="my.package.AnotherCustomResponseWriter" >
      <!-- initialization args may optionally be defined here -->
      <int name="someConfigValue">42</int>
-   </queryResponseWriter> 
+   </queryResponseWriter>
  }}}
- 
  === Similarity ===
- 
  The 
[[http://lucene.apache.org/java/docs/api/org/apache/lucene/search/Similarity.html|Similarity]]
 class is a native Lucene concept that determines how much of the score 
calculations for the various types of queries are executed. For more 
information on how the methods in the Similarity class are used, consult the 
[[http://lucene.apache.org/java/2_9_0/scoring.html|Lucene scoring 
documentation]].  If you wish to override the !DefaultSimilarity provided by 
Lucene, you can specify your own subclass in your [[SchemaXml|schema.xml]]...
  
  {{{
    <similarity class="my.package.CustomSimilarity"/>
  }}}
- 
- 
  === CacheRegenerator ===
- 
  The 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/search/CacheRegenerator.html|CacheRegenerator]]
 API allows people who are writing custom !SolrRequestHandlers which utilize 
custom [[SolrCaching|User Caches]] to specify how those caches should be 
populated during autowarming.  A regenerator class can be specified when the 
cache is declared in your [[SolrConfigXml|solrconfig.xml]]...
  
  {{{
@@ -150, +125 @@

        regenerator="my.package.CustomCacheRegenerator"
        />
  }}}
- 
- 
- 
  == Fields ==
- 
  === Analyzer ===
- 
  The 
[[http://lucene.apache.org/java/docs/api/org/apache/lucene/analysis/Analyzer.html|Analyzer]]
 class is a native Lucene concept that determines how tokens are produced from 
a piece of text.  Solr allows Analyzers to be specified for each fieldtype in 
your [[SchemaXml|schema.xml]] that uses the !TextField class -- and even allows 
for different Analyzers to be specified for indexing text as documents are 
added, and parsing text specified in a query...
  
  {{{
@@ -168, +138 @@

        <analyzer type="query" class="my.package.CustomAnalyzerForQuering"/>
      </fieldType>
  }}}
- 
  Solr also provides a 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/analysis/SolrAnalyzer.html|SolrAnalyzer]]
 base class which can be used if you want to write your own Analyzer and 
configure the "positionIncrementGap" in your schema.xml...
  
  {{{
@@ -176, +145 @@

        <analyzer class="my.package.CustomSolrAnalyzer" />
      </fieldType>
  }}}
- 
  Specifying an Analyzer class in your schema.xml makes a lot of sense if you 
already have an existing Analyzer you wish to use as is, but if you are 
planning to write Analysis code from scratch that you would like to use in 
Solr, you should keep reading the following sections...
  
  === Tokenizer and TokenFilter ===
- 
  In addition to specifing specific Analyzer classes, Solr can construct 
Analyzers on the fly for each field type using a 
[[http://lucene.apache.org/java/docs/api/org/apache/lucene/analysis/Tokenizer.html|Tokenizer]]
 and any number of 
[[http://lucene.apache.org/java/docs/api/org/apache/lucene/analysis/TokenFilter.html|TokenFilters]].
  To take advantage of this functionality with any Tokenizers or !TokenFilters 
you may have (or may want to implement) you'll need to provide a 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/analysis/TokenizerFactory.html|TokenizerFactory]]
 and 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/analysis/TokenFilterFactory.html|TokenFilterFactory]]
 which takes care of any initialization and configuration, and specify these 
Factories in your [[SchemaXml|schema.xml]]...
  
  {{{
@@ -194, +161 @@

        </analyzer>
      </fieldtype>
  }}}
- 
  === FieldType ===
- 
  If you have very specialized data type needs, you can specify your own 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/schema/FieldType.html|FieldType]]
 class for each <`fieldtype>` you declare in your [[SchemaXml|schema.xml]], to 
control how the values for those fields are encoded in your index...
  
  {{{
      <fieldtype name="wacko" class="my.package.CustomFieldType" />
  }}}
- 
  == Internals ==
- 
  === SolrCache ===
- 
  The 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/search/SolrCache.html|SolrCache]]
 API allows you to specify custom Cache implementations for any of the 
[[SolrCaching|various caches]] you might declare in your 
[[SolrConfigXml|solrconfig.xml]]...
  
  {{{
@@ -214, +176 @@

      <queryResultsCache class="my.package.CustomCache"          size="512"  />
      <documentCache     class="my.package.AlternateCustomCache" size="512"  />
  }}}
- 
  === SolrEventListener ===
- 
  Instances of the 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/core/SolrEventListener.html|SolrEventListener]]
 Interface can be configured in your [[SolrConfigXml|solrconfig.xml]] to be be 
executed any time specific events occur within Solr (currently, the only events 
that can be "listened" for are `firstSearcher` and `newSearcher`)...
  
  {{{
@@ -228, +188 @@

        <int name="otherArg">42</int>
      </listener>
  }}}
- 
  === UpdateHandler ===
- 
  The 
[[http://lucene.apache.org/solr/docs/api/org/apache/solr/update/UpdateHandler.html|UpdateHandler]]
 API allows you to specify a custom algorithm for determining how sequences of 
adds and deletes are processed by Solr.  The !UpdateHandler you wish to use can 
be configured in your [[SolrConfigXml|solrconfig.xml]], but implementing a new 
!UpdateHandler is considered '''extremely''' advanced and is not recommended....
  
  {{{
    <updateHandler class="my.package.CustomUpdateHandler">
- 
  }}}
- 
  = Building Plugins =
- 
  To develop your own plugins, add the `apache-solr-*.jar` jar files to the 
classpath you use to compile your code.  They contains all of the Solr 
Interfaces and Class files you may need.  If you are developing plugins that 
know about lower level Lucene interfaces, you may need to also include the 
`lucene-*.jar` jar files from the `lib/` directory of your Solr distribution.
  
- 
  = Plugin Initialization =
- 
  <!> [[Solr1.3]]
  
  Plugins are initialized either with 
[[http://svn.apache.org/repos/asf/lucene/solr/trunk/src/java/org/apache/solr/util/plugin/MapInitializedPlugin.java|init(
 Map<String,String> args )]] or 
[[http://svn.apache.org/repos/asf/lucene/solr/trunk/src/java/org/apache/solr/util/plugin/NamedListInitializedPlugin.java|init(
 NamedList args )]].
+ 
+ <!> [[Solr1.4]]
+ 
+ Plugins can also be initialized with 
[[http://svn.apache.org/repos/asf/lucene/solr/trunk/src/java/org/apache/solr/util/plugin/PluginInfoInitialized.java|init(
 PluginInfo info )]]. These Plugins can have children ( any Subnode with a 
"class" attribute is considered a child ).
+ If a pluginInfoInitialized Plugin wants to initialise these children in its 
{{{inform( core )}}} method via {{{ core.create.createInitInstance() }}}, the 
children must not be !SolrCoreAware.
+ see 
[[http://svn.apache.org/repos/asf/lucene/solr/trunk/src/java/org/apache/solr/core/PluginInfo.java|PluginInfo]].
+ 
  
  == ResourceLoaderAware ==
  Classes that need to know about the 
[[http://svn.apache.org/repos/asf/lucene/solr/trunk/src/java/org/apache/solr/common/ResourceLoader.java|ResourceLoader]]
 can implement 
[[http://svn.apache.org/repos/asf/lucene/solr/trunk/src/java/org/apache/solr/util/plugin/ResourceLoaderAware.java|ResourceLoaderAware]].
  Valid !ResourceLoaderAware include:
+ 
   * !TokenFilterFactory
   * !TokenizerFactory
   * !FieldType
  
  == SolrCoreAware ==
- Classes that need to know about the [SolrCore] can implement 
[[http://svn.apache.org/repos/asf/lucene/solr/trunk/src/java/org/apache/solr/util/plugin/SolrCoreAware.java|SolrCoreAware]].
  
+ Classes that need to know about the [SolrCore] can implement 
[[http://svn.apache.org/repos/asf/lucene/solr/trunk/src/java/org/apache/solr/util/plugin/SolrCoreAware.java|SolrCoreAware]].
   Classes implementing !SolrCoreAware must not have a dedicated Constructor. 
Valid !SolrCoreAware classes include:
+ 
- Classes implementing !SolrCoreAware must not have a constructor.
- Valid !SolrCoreAware classes include:
   * SolrRequestHandler
   * QueryResponseWriter
   * SearchComponent
  
  == Lifecycle ==
  The initialization lifecycle is:
+ 
   1. Constructor
-  2. {{{init( Map / NamedList )}}}
+  1. {{{init( Map / NamedList / PluginInfo )}}}
-  3. !ResourceLoaderAware classes call: {{{inform( ResourceLoader );}}}
+  1. !ResourceLoaderAware classes call: {{{inform( ResourceLoader );}}}
-  3. Before the first request is made and after all plugins have been created 
and registered, !SolrCoreAware plugins call: {{{inform( SolrCore );}}}
+  1. Before the first request is made and after all plugins have been created 
and registered, !SolrCoreAware plugins call: {{{inform( SolrCore );}}}
  

Reply via email to