lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jérôme Etévé" <jer...@eteve.net>
Subject Re: Pluggable IndexSearcher Proposal
Date Thu, 05 Jul 2007 17:46:41 GMT
Actually, I implemented that feature for the 1.2.0 version of solr
(the one I use)

It allows you to speficy the IndexSearcher used by solr in the schema
configuration file:

<!-- Custom Searcher class that must inherit from the lucene IndexSearcher
      and have a contructor with only one (IndexReader r) argument -->
 <searcher class="com.acme.lucene.search.MyGreatCustomSearcher"/>

If the specified class cant be loaded, a severe message is issued in
the log and solr
falls back to the hardcoded lucene IndexSearcher .

The patch to apply is attached to this email.

I also created an issue in the solr jira:
https://issues.apache.org/jira/browse/SOLR-288
but I didn t find the way to upload the patch.

Thanks for your comments.

Jerome.

On 7/5/07, Jérôme Etévé <jerome@eteve.net> wrote:
> Hi all !
>
> I need a new feature in solr : to allow the configuration of the
> IndexSearcher class in the schema configuration to override the lucene
> IndexSearcher .
> I noticed that there's only one point in the code where the searcher is built:
>
> <code>
> in org/apache/solr/search/SolrIndexSearcher.java:
>
>   private SolrIndexSearcher(IndexSchema schema, String name,
> IndexReader r, boolean closeReader, boolean enableCache) {
>     this.schema = schema;
>     this.name = "Searcher@" + Integer.toHexString(hashCode()) +
> (name!=null ? " "+name : "");
>
>     log.info("Opening " + this.name);
>
>     reader = r;
> /****** HERE *********/
>    searcher = new IndexSearcher(r);
> </code>
>
> I'd like to allow a new tag in the schema :
> <schema name="..." version="1.1">
>   <luceneIndexSearcher class="com.acme.lucene.searcher.MyOwnSearcher" />
> ....
> </schema>
>
> I dont exactly know what is the best way to do it.
> I was think of:
>
> * In IndexSchema:
>
> implement a method
> String getLuceneIndexSearcherClassName()
>
> * In SolrIndexSearcher
>   in  private SolrIndexSearcher:
>
>   String idxSearcherClassName = schema.getLuceneIndexSearcherClassName()
>   // Then load the class itself
>   // Then build a new instance of this class with the IndexReader r
>
>  What solr special class loader and instance builder do I have to use
> to do the last two operation ?
>
> Can I use directly :
>
> Class idxSearcherClass = Config.findClass(idxSearcherClassName)
>
> and then build a idxSearcher by using the standard java.lang.Class methods ?
>
> Am I in the right and does it fit with the solr architecture to do that ?
>
> I'd be perfectly happy to implement that and submit a patch.
>
> Thanks for your comments and answers.
>
> Jerome
>
> --
> Jerome Eteve.
> jerome@eteve.net
> http://jerome.eteve.free.fr/
>


-- 
Jerome Eteve.
jerome@eteve.net
http://jerome.eteve.free.fr/
Mime
View raw message