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 Pluggable IndexSearcher Proposal
Date Thu, 05 Jul 2007 14:45:31 GMT
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/

Mime
View raw message