SOLR-1566 -- passing SolrQueryRequest to DocTransformer

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1086699 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2011-03-29 19:40:37 +00:00
parent 9027875384
commit f6ddf2723a
6 changed files with 13 additions and 7 deletions

View File

@ -19,6 +19,7 @@ package org.apache.solr.response.transform;
import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.request.SolrQueryRequest;
/** /**
* @version $Id$ * @version $Id$
@ -27,7 +28,7 @@ import org.apache.solr.common.SolrException.ErrorCode;
public class DocIdAugmenterFactory extends TransformerFactory public class DocIdAugmenterFactory extends TransformerFactory
{ {
@Override @Override
public DocTransformer create(String field, String arg) { public DocTransformer create(String field, String arg, SolrQueryRequest req) {
if( arg != null ) { if( arg != null ) {
throw new SolrException( ErrorCode.BAD_REQUEST, throw new SolrException( ErrorCode.BAD_REQUEST,
"DocIdAugmenter does not take any arguments" ); "DocIdAugmenter does not take any arguments" );

View File

@ -23,6 +23,7 @@ import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.SolrPluginUtils; import org.apache.solr.util.SolrPluginUtils;
/** /**
@ -62,7 +63,7 @@ public class ExplainAugmenterFactory extends TransformerFactory
} }
@Override @Override
public DocTransformer create(String field, String arg) { public DocTransformer create(String field, String arg, SolrQueryRequest req) {
Style style = (arg==null)?defaultStyle:getStyle(arg); Style style = (arg==null)?defaultStyle:getStyle(arg);
return new ExplainAugmenter( field, style ); return new ExplainAugmenter( field, style );
} }

View File

@ -16,6 +16,8 @@
*/ */
package org.apache.solr.response.transform; package org.apache.solr.response.transform;
import org.apache.solr.request.SolrQueryRequest;
/** /**
* @version $Id$ * @version $Id$
@ -24,7 +26,7 @@ package org.apache.solr.response.transform;
public class ShardAugmenterFactory extends TransformerFactory public class ShardAugmenterFactory extends TransformerFactory
{ {
@Override @Override
public DocTransformer create(String field, String arg) { public DocTransformer create(String field, String arg, SolrQueryRequest req) {
String id = "TODO... find ID"; String id = "TODO... find ID";
// Maybe it is stored in the context? // Maybe it is stored in the context?
// is it a request variable? // is it a request variable?

View File

@ -20,7 +20,9 @@ package org.apache.solr.response.transform;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.plugin.NamedListInitializedPlugin; import org.apache.solr.util.plugin.NamedListInitializedPlugin;
/** /**
@ -36,7 +38,7 @@ public abstract class TransformerFactory implements NamedListInitializedPlugin
defaultUserArgs = (String)args.get( "args" ); defaultUserArgs = (String)args.get( "args" );
} }
public abstract DocTransformer create(String field, String args); public abstract DocTransformer create(String field, String args, SolrQueryRequest req);
public static final Map<String,TransformerFactory> defaultFactories = new HashMap<String,TransformerFactory>(); public static final Map<String,TransformerFactory> defaultFactories = new HashMap<String,TransformerFactory>();
static { static {

View File

@ -21,6 +21,7 @@ import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.util.DateUtil; import org.apache.solr.common.util.DateUtil;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
/** /**
* @version $Id$ * @version $Id$
@ -60,7 +61,7 @@ public class ValueAugmenterFactory extends TransformerFactory
} }
@Override @Override
public DocTransformer create(String field, String arg) { public DocTransformer create(String field, String arg, SolrQueryRequest req) {
Object val = value; Object val = value;
if( val == null ) { if( val == null ) {
val = (arg==null)?defaultValue:getObjectFrom(arg); val = (arg==null)?defaultValue:getObjectFrom(arg);

View File

@ -27,7 +27,6 @@ import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrCore;
import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequest;
@ -315,7 +314,7 @@ public class ReturnFields
TransformerFactory factory = req.getCore().getTransformerFactory( name ); TransformerFactory factory = req.getCore().getTransformerFactory( name );
if( factory != null ) { if( factory != null ) {
augmenters.addTransformer( factory.create(disp, args) ); augmenters.addTransformer( factory.create(disp, args, req) );
} }
else { else {
// unknown field? // unknown field?