I just tried, and it causes an NPE, kind of as I had expected. I’ll file the 
Jira.

-- Jack Krupansky

From: Dyer, James 
Sent: Monday, January 14, 2013 10:50 AM
To: dev@lucene.apache.org 
Subject: RE: Possible bug in Solr SpellCheckComponent if more than one 
QueryConverter class is present

Jack,

 

Did you test this to see if you could trigger this bug?  But in any case, can 
you open a jira ticket so this won't fall under the radar?  Even if the comment 
that was put here is true I guess we should minimally throw an exception, or 
use the first one and log a warning, maybe?

 

James Dyer

E-Commerce Systems

Ingram Content Group

(615) 213-4311

 

From: Jack Krupansky [mailto:j...@basetechnology.com] 
Sent: Sunday, January 13, 2013 1:24 PM
To: Lucene/Solr Dev
Subject: Possible bug in Solr SpellCheckComponent if more than one 
QueryConverter class is present

 

Reading through the code for Solr SpellCheckComponent.java for 4.1, it looks 
like it neither complains nor defaults reasonably if more than on 
QueryConverter class is present in the Solr lib directories:

 

Map<String, QueryConverter> queryConverters = new HashMap<String, 
QueryConverter>();

core.initPlugins(queryConverters,QueryConverter.class);

 

//ensure that there is at least one query converter defined

if (queryConverters.size() == 0) {

  LOG.info("No queryConverter defined, using default converter");

  queryConverters.put("queryConverter", new SpellingQueryConverter());

}

 

//there should only be one

if (queryConverters.size() == 1) {

  queryConverter = queryConverters.values().iterator().next();

  IndexSchema schema = core.getSchema();

  String fieldTypeName = (String) initParams.get("queryAnalyzerFieldType");

  FieldType fieldType = schema.getFieldTypes().get(fieldTypeName);

  Analyzer analyzer = fieldType == null ? new 
WhitespaceAnalyzer(core.getSolrConfig().luceneMatchVersion)

          : fieldType.getQueryAnalyzer();

  //TODO: There's got to be a better way!  Where's Spring when you need it?

  queryConverter.setAnalyzer(analyzer);

}

 

No else! And queryConverter is not initialized, except for that code path where 
there was zero or one QueryConverter class.


-- Jack Krupansky

Reply via email to