Java Code Examples for org.apache.solr.util.SolrPluginUtils

The following examples show how to use org.apache.solr.util.SolrPluginUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lucene-solr   Source File: LTRScoringModel.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"rawtypes"})
public static LTRScoringModel getInstance(SolrResourceLoader solrResourceLoader,
    String className, String name, List<Feature> features,
    List<Normalizer> norms,
    String featureStoreName, List<Feature> allFeatures,
    Map<String,Object> params) throws ModelException {
  final LTRScoringModel model;
  try {
    // create an instance of the model
    model = solrResourceLoader.newInstance(
        className,
        LTRScoringModel.class,
        new String[0], // no sub packages
        new Class[] { String.class, List.class, List.class, String.class, List.class, Map.class },
        new Object[] { name, features, norms, featureStoreName, allFeatures, params });
    if (params != null) {
      SolrPluginUtils.invokeSetters(model, params.entrySet());
    }
  } catch (final Exception e) {
    throw new ModelException("Model type does not exist " + className, e);
  }
  model.validate();
  return model;
}
 
Example 2
Source Project: lucene-solr   Source File: MetricSuppliers.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link Counter} supplier.
 * @param loader resource loader
 * @param info plugin configuration, or null for default
 * @return configured supplier instance, or default instance if configuration was invalid
 */
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Counter> counterSupplier(SolrResourceLoader loader, PluginInfo info) {
  if (info == null || info.className == null || info.className.trim().isEmpty()) {
    return new DefaultCounterSupplier();
  }

  MetricRegistry.MetricSupplier<Counter> supplier;
  try {
    supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
  } catch (Exception e) {
    log.warn("Error creating custom Counter supplier (will use default): {}", info, e);
    supplier = new DefaultCounterSupplier();
  }
  if (supplier instanceof PluginInfoInitialized) {
    ((PluginInfoInitialized)supplier).init(info);
  } else {
    SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
  }
  return supplier;
}
 
Example 3
Source Project: lucene-solr   Source File: MetricSuppliers.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link Meter} supplier.
 * @param loader resource loader
 * @param info plugin configuration, or null for default
 * @return configured supplier instance, or default instance if configuration was invalid
 */
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Meter> meterSupplier(SolrResourceLoader loader, PluginInfo info) {
  MetricRegistry.MetricSupplier<Meter> supplier;
  if (info == null || info.className == null || info.className.isEmpty()) {
    supplier = new DefaultMeterSupplier();
  } else {
    try {
      supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
    } catch (Exception e) {
      log.warn("Error creating custom Meter supplier (will use default): {}",info, e);
      supplier = new DefaultMeterSupplier();
    }
  }
  if (supplier instanceof PluginInfoInitialized) {
    ((PluginInfoInitialized)supplier).init(info);
  } else {
    SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
  }
  return supplier;
}
 
Example 4
Source Project: lucene-solr   Source File: MetricSuppliers.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link Timer} supplier.
 * @param loader resource loader
 * @param info plugin configuration, or null for default
 * @return configured supplier instance, or default instance if configuration was invalid
 */
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Timer> timerSupplier(SolrResourceLoader loader, PluginInfo info) {
  MetricRegistry.MetricSupplier<Timer> supplier;
  if (info == null || info.className == null || info.className.isEmpty()) {
    supplier = new DefaultTimerSupplier(loader);
  } else {
    try {
      supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
    } catch (Exception e) {
      log.warn("Error creating custom Timer supplier (will use default): {}", info, e);
      supplier = new DefaultTimerSupplier(loader);
    }
  }
  if (supplier instanceof PluginInfoInitialized) {
    ((PluginInfoInitialized)supplier).init(info);
  } else {
    SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
  }
  return supplier;
}
 
Example 5
Source Project: lucene-solr   Source File: MetricSuppliers.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link Histogram} supplier.
 * @param info plugin configuration, or null for default
 * @return configured supplier instance, or default instance if configuration was invalid
 */
@SuppressWarnings({"unchecked"})
public static MetricRegistry.MetricSupplier<Histogram> histogramSupplier(SolrResourceLoader loader, PluginInfo info) {
  MetricRegistry.MetricSupplier<Histogram> supplier;
  if (info == null || info.className == null || info.className.isEmpty()) {
    supplier = new DefaultHistogramSupplier(loader);
  } else {
    try {
      supplier = loader.newInstance(info.className, MetricRegistry.MetricSupplier.class);
    } catch (Exception e) {
      log.warn("Error creating custom Histogram supplier (will use default): {}", info, e);
      supplier = new DefaultHistogramSupplier(loader);
    }
  }
  if (supplier instanceof PluginInfoInitialized) {
    ((PluginInfoInitialized)supplier).init(info);
  } else {
    SolrPluginUtils.invokeSetters(supplier, info.initArgs, true);
  }
  return supplier;
}
 
Example 6
Source Project: lucene-solr   Source File: SolrMetricReporter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes a {@link SolrMetricReporter} with the plugin's configuration.
 *
 * @param pluginInfo the plugin's configuration
 */
@SuppressWarnings("unchecked")
public void init(PluginInfo pluginInfo) {
  if (pluginInfo != null) {
    this.pluginInfo = pluginInfo.copy();
    if (this.pluginInfo.initArgs != null) {
      SolrPluginUtils.invokeSetters(this, this.pluginInfo.initArgs);
    }
  }
  validate();
  if (!enabled) {
    log.info("Reporter disabled for registry {}", registryName);
    return;
  }
  log.debug("Initializing for registry {}", registryName);
  doInit();
}
 
Example 7
Source Project: lucene-solr   Source File: ExtendedDismaxQParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Extracts all the aliased fields from the requests and adds them to up
 */
private void addAliasesFromRequest(ExtendedSolrQueryParser up, float tiebreaker) {
  Iterator<String> it = config.solrParams.getParameterNamesIterator();
  while(it.hasNext()) {
    String param = it.next();
    if(param.startsWith("f.") && param.endsWith(".qf")) {
      // Add the alias
      String fname = param.substring(2,param.length()-3);
      String qfReplacement = config.solrParams.get(param);
      Map<String,Float> parsedQf = SolrPluginUtils.parseFieldBoosts(qfReplacement);
      if(parsedQf.size() == 0)
        return;
      up.addAlias(fname, tiebreaker, parsedQf);
    }
  }
}
 
Example 8
Source Project: lucene-solr   Source File: DisMaxQParser.java    License: Apache License 2.0 6 votes vote down vote up
protected Query getUserQuery(String userQuery, SolrPluginUtils.DisjunctionMaxQueryParser up, SolrParams solrParams)
        throws SyntaxError {


  String minShouldMatch = parseMinShouldMatch(req.getSchema(), solrParams);
  Query dis = up.parse(userQuery);
  Query query = dis;

  if (dis instanceof BooleanQuery) {
    BooleanQuery.Builder t = new BooleanQuery.Builder();
    SolrPluginUtils.flattenBooleanQuery(t, (BooleanQuery) dis);
    boolean mmAutoRelax = params.getBool(DisMaxParams.MM_AUTORELAX, false);
    SolrPluginUtils.setMinShouldMatch(t, minShouldMatch, mmAutoRelax);
    query = QueryUtils.build(t, this);
  }
  return query;
}
 
Example 9
Source Project: querqy   Source File: DismaxSearchEngineRequestAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Query applyMinimumShouldMatch(final BooleanQuery query) {

    final List<BooleanClause> clauses = query.clauses();
    if (clauses.size() < 2) {
        return query;
    }

    for (final BooleanClause clause : clauses) {
        if ((clause.getQuery() instanceof BooleanQuery) && (clause.getOccur() != BooleanClause.Occur.MUST)) {
            return query; // seems to be a complex query with sub queries - do not
            // apply mm
        }
    }

    return SolrPluginUtils.setMinShouldMatch(query, minShouldMatch);

}
 
Example 10
Source Project: lucene-solr   Source File: Feature.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"rawtypes"})
public static Feature getInstance(SolrResourceLoader solrResourceLoader,
    String className, String name, Map<String,Object> params) {
  final Feature f = solrResourceLoader.newInstance(
      className,
      Feature.class,
      new String[0], // no sub packages
      new Class[] { String.class, Map.class },
      new Object[] { name, params });
  if (params != null) {
    SolrPluginUtils.invokeSetters(f, params.entrySet());
  }
  f.validate();
  return f;
}
 
Example 11
Source Project: lucene-solr   Source File: Normalizer.java    License: Apache License 2.0 5 votes vote down vote up
public static Normalizer getInstance(SolrResourceLoader solrResourceLoader,
    String className, Map<String,Object> params) {
  final Normalizer f = solrResourceLoader.newInstance(className, Normalizer.class);
  if (params != null) {
    SolrPluginUtils.invokeSetters(f, params.entrySet());
  }
  f.validate();
  return f;
}
 
Example 12
@Override
@SuppressWarnings({"unchecked"})
public void init(@SuppressWarnings("rawtypes") NamedList args) {
  super.init(args);
  threadManager = LTRThreadModule.getInstance(args);
  SolrPluginUtils.invokeSetters(this, args);
}
 
Example 13
Source Project: lucene-solr   Source File: LTRQParserPlugin.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked"})
public void init(@SuppressWarnings("rawtypes") NamedList args) {
  super.init(args);
  threadManager = LTRThreadModule.getInstance(args);
  SolrPluginUtils.invokeSetters(this, args);
}
 
Example 14
Source Project: lucene-solr   Source File: MultipleAdditiveTreesModel.java    License: Apache License 2.0 5 votes vote down vote up
private RegressionTree createRegressionTree(Map<String,Object> map) {
  final RegressionTree rt = new RegressionTree();
  if (map != null) {
    SolrPluginUtils.invokeSetters(rt, map.entrySet());
  }
  return rt;
}
 
Example 15
Source Project: lucene-solr   Source File: MultipleAdditiveTreesModel.java    License: Apache License 2.0 5 votes vote down vote up
private RegressionTreeNode createRegressionTreeNode(Map<String,Object> map) {
  final RegressionTreeNode rtn = new RegressionTreeNode();
  if (map != null) {
    SolrPluginUtils.invokeSetters(rtn, map.entrySet());
  }
  return rtn;
}
 
Example 16
Source Project: lucene-solr   Source File: NeuralNetworkModel.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked"})
protected Layer createLayer(Object o) {
  final DefaultLayer layer = new DefaultLayer();
  if (o != null) {
    SolrPluginUtils.invokeSetters(layer, ((Map<String,Object>) o).entrySet());
  }
  return layer;
}
 
Example 17
Source Project: lucene-solr   Source File: LTRThreadModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked"})
public void init(@SuppressWarnings({"rawtypes"})NamedList args) {
  if (args != null) {
    SolrPluginUtils.invokeSetters(this, args);
  }
  validate();
  if  (this.totalPoolThreads > 1 ){
    ltrSemaphore = new Semaphore(totalPoolThreads);
  } else {
    ltrSemaphore = null;
  }
}
 
Example 18
Source Project: lucene-solr   Source File: TestNeuralNetworkModel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked"})
protected Layer createLayer(Object o) {
  final DefaultLayer layer = new DefaultLayer();
  if (o != null) {
    SolrPluginUtils.invokeSetters(layer, ((Map<String,Object>) o).entrySet());
  }
  return layer;
}
 
Example 19
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
                                          SolrQueryResponse rsp, UpdateRequestProcessor next) {
  // Process defaults, appends and invariants if we got a request
  if(req != null) {
    SolrPluginUtils.setDefaults(req, defaults, appends, invariants);
  }
  return new TikaLanguageIdentifierUpdateProcessor(req, rsp, next);
}
 
Example 20
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
                                          SolrQueryResponse rsp, UpdateRequestProcessor next) {
  // Process defaults, appends and invariants if we got a request
  if(req != null) {
    SolrPluginUtils.setDefaults(req, defaults, appends, invariants);
  }
  return new LangDetectLanguageIdentifierUpdateProcessor(req, rsp, next);
}
 
Example 21
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {
  // Process defaults, appends and invariants if we got a request
  if (req != null) {
    SolrPluginUtils.setDefaults(req, defaults, appends, invariants);
  }
  return new OpenNLPLangDetectUpdateProcessor(req, rsp, next, model);
}
 
Example 22
Source Project: lucene-solr   Source File: ExplainAugmenterFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void transform(SolrDocument doc, int docid) throws IOException {
  if( context != null && context.getQuery() != null ) {
    Explanation exp = context.getSearcher().explain(context.getQuery(), docid);
    if( style == Style.nl ) {
      doc.setField( name, SolrPluginUtils.explanationToNamedList(exp) );
    }
    else if( style == Style.html ) {
      doc.setField( name, toHtml(exp));
    }
    else {
      doc.setField( name, exp.toString() );
    }
  }
}
 
Example 23
Source Project: lucene-solr   Source File: SolrIndexConfig.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked"})
private MergeScheduler buildMergeScheduler(SolrResourceLoader resourceLoader) {
  String msClassName = mergeSchedulerInfo == null ? SolrIndexConfig.DEFAULT_MERGE_SCHEDULER_CLASSNAME : mergeSchedulerInfo.className;
  MergeScheduler scheduler = resourceLoader.newInstance(msClassName, MergeScheduler.class);

  if (mergeSchedulerInfo != null) {
    // LUCENE-5080: these two setters are removed, so we have to invoke setMaxMergesAndThreads
    // if someone has them configured.
    if (scheduler instanceof ConcurrentMergeScheduler) {
      @SuppressWarnings({"rawtypes"})
      NamedList args = mergeSchedulerInfo.initArgs.clone();
      Integer maxMergeCount = (Integer) args.remove("maxMergeCount");
      if (maxMergeCount == null) {
        maxMergeCount = ((ConcurrentMergeScheduler) scheduler).getMaxMergeCount();
      }
      Integer maxThreadCount = (Integer) args.remove("maxThreadCount");
      if (maxThreadCount == null) {
        maxThreadCount = ((ConcurrentMergeScheduler) scheduler).getMaxThreadCount();
      }
      ((ConcurrentMergeScheduler)scheduler).setMaxMergesAndThreads(maxMergeCount, maxThreadCount);
      Boolean ioThrottle = (Boolean) args.remove("ioThrottle");
      if (ioThrottle != null && !ioThrottle) { //by-default 'enabled'
          ((ConcurrentMergeScheduler) scheduler).disableAutoIOThrottle();
      }
      SolrPluginUtils.invokeSetters(scheduler, args);
    } else {
      SolrPluginUtils.invokeSetters(scheduler, mergeSchedulerInfo.initArgs);
    }
  }

  return scheduler;
}
 
Example 24
Source Project: lucene-solr   Source File: ExtendedDismaxQParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Parses an escaped version of the user's query.  This method is called 
 * in the event that the original query encounters exceptions during parsing.
 *
 * @param up parser used
 * @param escapedUserQuery query that is parsed, should already be escaped so that no trivial parse errors are encountered
 * @param config Configuration options for this parse request
 * @return the resulting query (flattened if needed) with "min should match" rules applied as specified in the config.
 * @see #parseOriginalQuery
 * @see SolrPluginUtils#flattenBooleanQuery
 */
protected Query parseEscapedQuery(ExtendedSolrQueryParser up,
    String escapedUserQuery, ExtendedDismaxConfiguration config) throws SyntaxError {
  Query query = up.parse(escapedUserQuery);
  
  if (query instanceof BooleanQuery) {
    BooleanQuery.Builder t = new BooleanQuery.Builder();
    SolrPluginUtils.flattenBooleanQuery(t, (BooleanQuery)query);
    SolrPluginUtils.setMinShouldMatch(t, config.minShouldMatch, config.mmAutoRelax);
    query = QueryUtils.build(t, this);
  }
  return query;
}
 
Example 25
Source Project: lucene-solr   Source File: ExtendedDismaxQParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Parses the user's original query.  This method attempts to cleanly parse the specified query string using the specified parser, any Exceptions are ignored resulting in null being returned.
 *
 * @param up parser used
 * @param mainUserQuery query string that is parsed
 * @param clauses used to dictate "min should match" logic
 * @param config Configuration options for this parse request
 * @return the resulting query with "min should match" rules applied as specified in the config.
 * @see #parseEscapedQuery
 */
 protected Query parseOriginalQuery(ExtendedSolrQueryParser up,
    String mainUserQuery, List<Clause> clauses, ExtendedDismaxConfiguration config) {
  
  Query query = null;
  try {
    up.setRemoveStopFilter(!config.stopwords);
    up.exceptions = true;
    query = up.parse(mainUserQuery);
    
    if (shouldRemoveStopFilter(config, query)) {
      // if the query was all stop words, remove none of them
      up.setRemoveStopFilter(true);
      query = up.parse(mainUserQuery);          
    }
  } catch (Exception e) {
    // ignore failure and reparse later after escaping reserved chars
    up.exceptions = false;
  }
  
  if(query == null) {
    return null;
  }
  // For correct lucene queries, turn off mm processing if no explicit mm spec was provided
  // and there were explicit operators (except for AND).
  if (query instanceof BooleanQuery) {
    // config.minShouldMatch holds the value of mm which MIGHT have come from the user,
    // but could also have been derived from q.op.
    String mmSpec = config.minShouldMatch;

    if (foundOperators(clauses, config.lowercaseOperators)) {
      mmSpec = config.solrParams.get(DisMaxParams.MM, "0%"); // Use provided mm spec if present, otherwise turn off mm processing
    }
    query = SolrPluginUtils.setMinShouldMatch((BooleanQuery)query, mmSpec, config.mmAutoRelax);
  }
  return query;
}
 
Example 26
Source Project: lucene-solr   Source File: DisMaxQParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Uses {@link SolrPluginUtils#parseFieldBoosts(String)} with the 'qf' parameter. Falls back to the 'df' parameter
 */
public static Map<String, Float> parseQueryFields(final IndexSchema indexSchema, final SolrParams solrParams)
    throws SyntaxError {
  Map<String, Float> queryFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.QF));
  if (queryFields.isEmpty()) {
    String df = solrParams.get(CommonParams.DF);
    if (df == null) {
      throw new SyntaxError("Neither "+DisMaxParams.QF+" nor "+CommonParams.DF +" are present.");
    }
    queryFields.put(df, 1.0f);
  }
  return queryFields;
}
 
Example 27
Source Project: lucene-solr   Source File: DisMaxQParser.java    License: Apache License 2.0 5 votes vote down vote up
/** Adds the main query to the query argument. If it's blank then false is returned. */
protected boolean addMainQuery(BooleanQuery.Builder query, SolrParams solrParams) throws SyntaxError {
  Map<String, Float> phraseFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.PF));
  float tiebreaker = solrParams.getFloat(DisMaxParams.TIE, 0.0f);

  /* a parser for dealing with user input, which will convert
   * things to DisjunctionMaxQueries
   */
  SolrPluginUtils.DisjunctionMaxQueryParser up = getParser(queryFields, DisMaxParams.QS, solrParams, tiebreaker);

  /* for parsing sloppy phrases using DisjunctionMaxQueries */
  SolrPluginUtils.DisjunctionMaxQueryParser pp = getParser(phraseFields, DisMaxParams.PS, solrParams, tiebreaker);

  /* * * Main User Query * * */
  parsedUserQuery = null;
  String userQuery = getString();
  altUserQuery = null;
  if (StringUtils.isBlank(userQuery)) {
    // If no query is specified, we may have an alternate
    altUserQuery = getAlternateUserQuery(solrParams);
    if (altUserQuery == null)
      return false;
    query.add(altUserQuery, BooleanClause.Occur.MUST);
  } else {
    // There is a valid query string
    userQuery = SolrPluginUtils.partialEscape(SolrPluginUtils.stripUnbalancedQuotes(userQuery)).toString();
    userQuery = SolrPluginUtils.stripIllegalOperators(userQuery).toString();

    parsedUserQuery = getUserQuery(userQuery, up, solrParams);
    query.add(parsedUserQuery, BooleanClause.Occur.MUST);

    Query phrase = getPhraseQuery(userQuery, pp);
    if (null != phrase) {
      query.add(phrase, BooleanClause.Occur.SHOULD);
    }
  }
  return true;
}
 
Example 28
Source Project: lucene-solr   Source File: DisMaxQParser.java    License: Apache License 2.0 5 votes vote down vote up
protected Query getPhraseQuery(String userQuery, SolrPluginUtils.DisjunctionMaxQueryParser pp) throws SyntaxError {
  /* * * Add on Phrases for the Query * * */

  /* build up phrase boosting queries */

  /* if the userQuery already has some quotes, strip them out.
   * we've already done the phrases they asked for in the main
   * part of the query, this is to boost docs that may not have
   * matched those phrases but do match looser phrases.
  */
  String userPhraseQuery = userQuery.replace("\"", "");
  return pp.parse("\"" + userPhraseQuery + "\"");
}
 
Example 29
Source Project: lucene-solr   Source File: DisMaxQParser.java    License: Apache License 2.0 5 votes vote down vote up
protected SolrPluginUtils.DisjunctionMaxQueryParser getParser(Map<String, Float> fields, String paramName,
                                                              SolrParams solrParams, float tiebreaker) {
  int slop = solrParams.getInt(paramName, 0);
  SolrPluginUtils.DisjunctionMaxQueryParser parser = new SolrPluginUtils.DisjunctionMaxQueryParser(this,
          IMPOSSIBLE_FIELD_NAME);
  parser.addAlias(IMPOSSIBLE_FIELD_NAME, tiebreaker, fields);
  parser.setPhraseSlop(slop);
  parser.setSplitOnWhitespace(true);
  return parser;
}
 
Example 30
Source Project: lucene-solr   Source File: TermVectorComponent.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void finishStage(ResponseBuilder rb) {
  if (rb.stage == ResponseBuilder.STAGE_GET_FIELDS) {
    
    NamedList<Object> termVectorsNL = new NamedList<>();

    @SuppressWarnings({"unchecked", "rawtypes"})
    Map.Entry<String, Object>[] arr = new NamedList.NamedListEntry[rb.resultIds.size()];

    for (ShardRequest sreq : rb.finished) {
      if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) == 0 || !sreq.params.getBool(COMPONENT_NAME, false)) {
        continue;
      }
      for (ShardResponse srsp : sreq.responses) {
        @SuppressWarnings({"unchecked"})
        NamedList<Object> nl = (NamedList<Object>)srsp.getSolrResponse().getResponse().get(TERM_VECTORS);

        // Add metadata (that which isn't a uniqueKey value):
        Object warningsNL = nl.get(TV_KEY_WARNINGS);
        // assume if that if warnings is already present; we don't need to merge.
        if (warningsNL != null && termVectorsNL.indexOf(TV_KEY_WARNINGS, 0) < 0) {
          termVectorsNL.add(TV_KEY_WARNINGS, warningsNL);
        }

        // UniqueKey data
        SolrPluginUtils.copyNamedListIntoArrayByDocPosInResponse(nl, rb.resultIds, arr);
      }
    }
    // remove nulls in case not all docs were able to be retrieved
    SolrPluginUtils.removeNulls(arr, termVectorsNL);
    rb.rsp.add(TERM_VECTORS, termVectorsNL);
  }
}