use of org.apache.lucene.queryparser.xml.builders.SpanQueryBuilder in project lucene-solr by apache.
the class SolrCoreParser method init.
@Override
public void init(NamedList initArgs) {
if (initArgs == null || initArgs.size() == 0) {
return;
}
final SolrResourceLoader loader;
if (req == null) {
loader = new SolrResourceLoader();
} else {
loader = req.getCore().getResourceLoader();
}
final Iterable<Map.Entry<String, Object>> args = initArgs;
for (final Map.Entry<String, Object> entry : args) {
final String queryName = entry.getKey();
final String queryBuilderClassName = (String) entry.getValue();
try {
final SolrSpanQueryBuilder spanQueryBuilder = loader.newInstance(queryBuilderClassName, SolrSpanQueryBuilder.class, null, new Class[] { String.class, Analyzer.class, SolrQueryRequest.class, SpanQueryBuilder.class }, new Object[] { defaultField, analyzer, req, this });
this.addSpanQueryBuilder(queryName, spanQueryBuilder);
} catch (Exception outerException) {
try {
final SolrQueryBuilder queryBuilder = loader.newInstance(queryBuilderClassName, SolrQueryBuilder.class, null, new Class[] { String.class, Analyzer.class, SolrQueryRequest.class, QueryBuilder.class }, new Object[] { defaultField, analyzer, req, this });
this.addQueryBuilder(queryName, queryBuilder);
} catch (Exception innerException) {
log.error("Class {} not found or not suitable: {} {}", queryBuilderClassName, outerException, innerException);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Cannot find suitable " + SolrSpanQueryBuilder.class.getCanonicalName() + " or " + SolrQueryBuilder.class.getCanonicalName() + " class: " + queryBuilderClassName + " in " + loader);
}
}
}
}
Aggregations