当前位置: 首页>>代码示例>>Java>>正文


Java SolrParams.getParameterNamesIterator方法代码示例

本文整理汇总了Java中org.apache.solr.common.params.SolrParams.getParameterNamesIterator方法的典型用法代码示例。如果您正苦于以下问题:Java SolrParams.getParameterNamesIterator方法的具体用法?Java SolrParams.getParameterNamesIterator怎么用?Java SolrParams.getParameterNamesIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.common.params.SolrParams的用法示例。


在下文中一共展示了SolrParams.getParameterNamesIterator方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyIfNotNull

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private static void copyIfNotNull(SolrParams params, Map<String, Object> props, String... keys) {
  ArrayList<String> prefixes = new ArrayList<>(1);
  if(keys !=null){
    for (String key : keys) {
      if(key.endsWith(".")) {
        prefixes.add(key);
        continue;
      }
      String v = params.get(key);
      if(v != null) props.put(key,v);
    }
  }
  if(prefixes.isEmpty()) return;
  Iterator<String> it = params.getParameterNamesIterator();
  String prefix = null;
  for(;it.hasNext();){
    String name = it.next();
    for (int i = 0; i < prefixes.size(); i++) {
      if(name.startsWith(prefixes.get(i))){
        String val = params.get(name);
        if(val !=null) props.put(name,val);
      }
    }
  }

}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:CollectionsHandler.java

示例2: prepare

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {

    if (isEnabled(rb)) {
        rb.setNeedDocSet(true);

        // De-duplicate field list
        ModifiableSolrParams params = new ModifiableSolrParams();
        SolrParams origParams = rb.req.getParams();
        Iterator<String> iter = origParams.getParameterNamesIterator();
        while (iter.hasNext()) {
            String paramName = iter.next();
            // Deduplicate the list with LinkedHashSet, but _only_ for facet params.
            if (!paramName.equals(JointProbabilityParams.FIELDS)) {
                params.add(paramName, origParams.getParams(paramName));
                continue;
            }
            HashSet<String> deDupe = new LinkedHashSet<String>(Arrays.asList(origParams.getParams(paramName)));
            params.add(paramName, deDupe.toArray(new String[deDupe.size()]));
        }
        rb.req.setParams(params);
    }
}
 
开发者ID:DiceTechJobs,项目名称:SolrPlugins,代码行数:24,代码来源:JointProbabilityComponent.java

示例3: prepare

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {
  if (rb.req.getParams().getBool(FacetParams.FACET, false)) {
    rb.setNeedDocSet(true);
    rb.doFacets = true;

    // Deduplicate facet params
    ModifiableSolrParams params = new ModifiableSolrParams();
    SolrParams origParams = rb.req.getParams();
    Iterator<String> iter = origParams.getParameterNamesIterator();
    while (iter.hasNext()) {
      String paramName = iter.next();
      // Deduplicate the list with LinkedHashSet, but _only_ for facet params.
      if (!paramName.startsWith(FacetParams.FACET)) {
        params.add(paramName, origParams.getParams(paramName));
        continue;
      }
      HashSet<String> deDupe = new LinkedHashSet<>(Arrays.asList(origParams.getParams(paramName)));
      params.add(paramName, deDupe.toArray(new String[deDupe.size()]));

    }
    rb.req.setParams(params);

    // Initialize context
    FacetContext.initContext(rb);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:28,代码来源:FacetComponent.java

示例4: toMultiMap

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/** Create a Map&lt;String,String[]&gt; from {@link org.apache.solr.common.params.SolrParams}*/
public static Map<String, String[]> toMultiMap(SolrParams solrParams) {
  HashMap<String,String[]> multiValuedMap = new HashMap<String, String[]>();
  Iterator<String> params = solrParams.getParameterNamesIterator();
  while (params.hasNext()) {
    String param = params.next();
    String[] values = solrParams.getParams(param);
    if (values != null) {
      multiValuedMap.put(param, values);
    }
  }
  return multiValuedMap;
}
 
开发者ID:lucidworks,项目名称:fusion-solr-plugins,代码行数:14,代码来源:LogToFusionComponent.java

示例5: toQueryString

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public static String toQueryString( SolrParams params, boolean xml ) {
  StringBuilder sb = new StringBuilder(128);
  try {
    String amp = xml ? "&amp;" : "&";
    boolean first=true;
    Iterator<String> names = params.getParameterNamesIterator();
    while( names.hasNext() ) {
      String key = names.next();
      String[] valarr = params.getParams( key );
      if( valarr == null ) {
        sb.append( first?"?":amp );
        sb.append(key);
        first=false;
      }
      else {
        for (String val : valarr) {
          sb.append( first? "?":amp );
          sb.append(key);
          if( val != null ) {
            sb.append('=');
            sb.append( URLEncoder.encode( val, "UTF-8" ) );
          }
          first=false;
        }
      }
    }
  }
  catch (IOException e) {throw new RuntimeException(e);}  // can't happen
  return sb.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:ClientUtils.java

示例6: extractCarrotAttributes

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
 * Extracts parameters that can possibly match some attributes of Carrot2 algorithms.
 */
private void extractCarrotAttributes(SolrParams solrParams,
                                     Map<String, Object> attributes) {
  // Extract all non-predefined parameters. This way, we'll be able to set all
  // parameters of Carrot2 algorithms without defining their names as constants.
  for (Iterator<String> paramNames = solrParams.getParameterNamesIterator(); paramNames
          .hasNext();) {
    String paramName = paramNames.next();
    if (!CarrotParams.CARROT_PARAM_NAMES.contains(paramName)) {
      attributes.put(paramName, solrParams.get(paramName));
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:CarrotClusteringEngine.java

示例7: getParamsMap

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private Map<String, Object> getParamsMap(SolrParams params) {
  Iterator<String> names = params.getParameterNamesIterator();
  Map<String, Object> result = new HashMap<>();
  while (names.hasNext()) {
    String s = names.next();
    String[] val = params.getParams(s);
    if (val == null || val.length < 1)
      continue;
    if (val.length == 1)
      result.put(s, val[0]);
    else
      result.put(s, Arrays.asList(val));
  }
  return result;
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:DataImportHandler.java

示例8: copyPropertiesIfNotNull

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private void copyPropertiesIfNotNull(SolrParams params, Map<String, Object> props) {
  Iterator<String> iter =  params.getParameterNamesIterator();
  while (iter.hasNext()) {
    String param = iter.next();
    if (param.startsWith(OverseerCollectionProcessor.COLL_PROP_PREFIX)) {
      props.put(param, params.get(param));
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:CollectionsHandler.java

示例9: validateCommitParams

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
public static void validateCommitParams(SolrParams params) {
  Iterator<String> i = params.getParameterNamesIterator();
  while (i.hasNext()) {
    String key = i.next();
    if (!commitParams.contains(key)) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown commit parameter '" + key + "'");
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:RequestHandlerUtils.java

示例10: process

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
 * Actually run the query
 */
@Override
public void process(ResponseBuilder rb) throws IOException {

  //SolrParams params = rb.req.getParams();
  if (rb.doFacets) {
    ModifiableSolrParams params = new ModifiableSolrParams();
    SolrParams origParams = rb.req.getParams();
    Iterator<String> iter = origParams.getParameterNamesIterator();
    while (iter.hasNext()) {
      String paramName = iter.next();
      // Deduplicate the list with LinkedHashSet, but _only_ for facet params.
      if (paramName.startsWith(FacetParams.FACET) == false) {
        params.add(paramName, origParams.getParams(paramName));
        continue;
      }
      HashSet<String> deDupe = new LinkedHashSet<>(Arrays.asList(origParams.getParams(paramName)));
      params.add(paramName, deDupe.toArray(new String[deDupe.size()]));
    }

    SimpleFacets f = new SimpleFacets(rb.req, rb.getResults().docSet, params, rb);
    
    NamedList<Object> counts = f.getFacetCounts();
    String[] pivots = params.getParams(FacetParams.FACET_PIVOT);
    if (pivots != null && pivots.length > 0) {
      PivotFacetProcessor pivotProcessor 
        = new PivotFacetProcessor(rb.req, rb.getResults().docSet, params, rb);
      SimpleOrderedMap<List<NamedList<Object>>> v 
        = pivotProcessor.process(pivots);
      if (v != null) {
        counts.add(PIVOT_KEY, v);
      }
    }
    
    rb.rsp.add("facet_counts", counts);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:40,代码来源:FacetComponent.java

示例11: handleRequestBody

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
 * Expands aliases into queries for thematic collections.
 * 
 * Operates by taking apart the passed request, scanning it for thematic-collection keywords,
 * and replacing those it finds with the appropriate expanded query.
 * 
 * @author thill
 * @version 2017.11.14
 */

@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
    throws Exception {
  
  AliasConfig aliasConfig = req.getCore().getAliasConfig();
  HashMap<String, HashMap<String, String>> aliases = aliasConfig.getAliases();
  SolrParams params = req.getParams();
  Iterator<String> pnit = params.getParameterNamesIterator();
  Map<String, String[]> modifiedParams = new HashMap<String, String[]>();
  String paramnames = "";
  while(pnit.hasNext()) {
    
    String pname = pnit.next();
    paramnames += pname + " ";
    String[] pvalues = params.getParams(pname);
    if(!pname.equals("q") && !pname.equals("fq")) {
      
      modifiedParams.put(pname, pvalues);
      
    }
    else {
      String[] modifiedValues = this.modifyValues(aliases, pvalues);
      modifiedParams.put(pname, modifiedValues);
    
    }
    
  }
  MultiMapSolrParams newParams = new MultiMapSolrParams(modifiedParams);
  req.setParams(newParams);
  // a little debugging check
  //String paramCheck = outputParams(newParams);
  // rsp.add("test", paramCheck);
  super.handleRequestBody(req, rsp);
  
}
 
开发者ID:europeana,项目名称:search,代码行数:46,代码来源:AliasingRequestHandler.java

示例12: getCustomParams

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
 * For every param that is of the form "spellcheck.[dictionary name].XXXX=YYYY, add
 * XXXX=YYYY as a param to the custom param list
 * @param params The original SolrParams
 * @return The new Params
 */
protected SolrParams getCustomParams(String dictionary, SolrParams params) {
  ModifiableSolrParams result = new ModifiableSolrParams();
  Iterator<String> iter = params.getParameterNamesIterator();
  String prefix = SpellingParams.SPELLCHECK_PREFIX + "." + dictionary + ".";
  while (iter.hasNext()){
    String nxt = iter.next();
    if (nxt.startsWith(prefix)){
      result.add(nxt.substring(prefix.length()), params.getParams(nxt));
    }
  }
  return result;
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:SpellCheckComponent.java

示例13: outputParams

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
private String outputParams(SolrParams params) {
  
  // for debugging purposes
  
  StringBuilder sb = new StringBuilder();
  Iterator<String> pit = params.getParameterNamesIterator();
  
  while(pit.hasNext()) {
    
    String pname = pit.next();
    sb.append(pname);
    sb.append(" :");
    String[] pvalues = params.getParams(pname);
    for(int i = 0; i < pvalues.length; i++) {
      
      sb.append(pvalues[i]);
      sb.append(" ");
      
    }
    sb.append("\n\n");
    
  }
  
  return sb.toString();
  
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:AliasingRequestHandler.java


注:本文中的org.apache.solr.common.params.SolrParams.getParameterNamesIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。