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


Java MultiMapSolrParams.addParam方法代码示例

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


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

示例1: toMultiMap

import org.apache.solr.common.params.MultiMapSolrParams; //导入方法依赖的package包/类
static Map<String, String[]> toMultiMap(ModifiableSolrParams solrQueryParameter) {
    NamedList<Object> namedList = solrQueryParameter.toNamedList();
    //disabled for MCR-953 and https://issues.apache.org/jira/browse/SOLR-7508
    //Map<String, String[]> parameters = ModifiableSolrParams.toMultiMap(namedList);
    HashMap<String, String[]> parameters = new HashMap<>();
    for (int i = 0; i < namedList.size(); i++) {
        String name = namedList.getName(i);
        Object val = namedList.getVal(i);
        if (val instanceof String[]) {
            MultiMapSolrParams.addParam(name, (String[]) val, parameters);
        } else {
            MultiMapSolrParams.addParam(name, val.toString(), parameters);
        }
    }
    //end of fix
    return parameters;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:18,代码来源:MCRSolrProxyServlet.java

示例2: decodeBuffer

import org.apache.solr.common.params.MultiMapSolrParams; //导入方法依赖的package包/类
private static void decodeBuffer(final LinkedList<Object> input, final Map<String,String[]> map, CharsetDecoder charsetDecoder) {
  for (final Iterator<Object> it = input.iterator(); it.hasNext(); ) {
    final byte[] keyBytes = (byte[]) it.next();
    it.remove();
    final Long keyPos = (Long) it.next();
    it.remove();
    final byte[] valueBytes = (byte[]) it.next();
    it.remove();
    final Long valuePos = (Long) it.next();
    it.remove();
    MultiMapSolrParams.addParam(decodeChars(keyBytes, keyPos.longValue(), charsetDecoder),
        decodeChars(valueBytes, valuePos.longValue(), charsetDecoder), map);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:SolrRequestParsers.java

示例3: parseParamsAndFillStreams

import org.apache.solr.common.params.MultiMapSolrParams; //导入方法依赖的package包/类
@Override
public SolrParams parseParamsAndFillStreams( 
    final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception
{
  if( !ServletFileUpload.isMultipartContent(req) ) {
    throw new SolrException( ErrorCode.BAD_REQUEST, "Not multipart content! "+req.getContentType() );
  }
  
  MultiMapSolrParams params = parseQueryString( req.getQueryString() );
  
  // Create a factory for disk-based file items
  DiskFileItemFactory factory = new DiskFileItemFactory();

  // Set factory constraints
  // TODO - configure factory.setSizeThreshold(yourMaxMemorySize);
  // TODO - configure factory.setRepository(yourTempDirectory);

  // Create a new file upload handler
  ServletFileUpload upload = new ServletFileUpload(factory);
  upload.setSizeMax( ((long) uploadLimitKB) * 1024L );

  // Parse the request
  List items = upload.parseRequest(req);
  Iterator iter = items.iterator();
  while (iter.hasNext()) {
      FileItem item = (FileItem) iter.next();

      // If its a form field, put it in our parameter map
      if (item.isFormField()) {
        MultiMapSolrParams.addParam( 
          item.getFieldName(), 
          item.getString(), params.getMap() );
      }
      // Add the stream
      else { 
        streams.add( new FileItemContentStream( item ) );
      }
  }
  return params;
}
 
开发者ID:europeana,项目名称:search,代码行数:41,代码来源:SolrRequestParsers.java

示例4: parseParamsAndFillStreams

import org.apache.solr.common.params.MultiMapSolrParams; //导入方法依赖的package包/类
@Override
public SolrParams parseParamsAndFillStreams( 
    final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception
{
  if( !ServletFileUpload.isMultipartContent(req) ) {
    throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Not multipart content! "+req.getContentType() );
  }
  
  MultiMapSolrParams params = SolrRequestParsers.parseQueryString( req.getQueryString() );
  
  // Create a factory for disk-based file items
  DiskFileItemFactory factory = new DiskFileItemFactory();

  // Set factory constraints
  // TODO - configure factory.setSizeThreshold(yourMaxMemorySize);
  // TODO - configure factory.setRepository(yourTempDirectory);

  // Create a new file upload handler
  ServletFileUpload upload = new ServletFileUpload(factory);
  upload.setSizeMax( ((long) uploadLimitKB) * 1024L );

  // Parse the request
  List items = upload.parseRequest(req);
  Iterator iter = items.iterator();
  while (iter.hasNext()) {
      FileItem item = (FileItem) iter.next();

      // If its a form field, put it in our parameter map
      if (item.isFormField()) {
        MultiMapSolrParams.addParam( 
          item.getFieldName(), 
          item.getString(), params.getMap() );
      }
      // Add the stream
      else { 
        streams.add( new FileItemContentStream( item ) );
      }
  }
  return params;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:41,代码来源:SolrRequestParsers.java

示例5: parseFormDataContent

import org.apache.solr.common.params.MultiMapSolrParams; //导入方法依赖的package包/类
/**
 * Given a url-encoded form from POST content (as InputStream), map it into the given map.
 * The given InputStream should be buffered!
 * @param postContent to be parsed
 * @param charset to be used to decode resulting bytes after %-decoding
 * @param map place all parameters in this map
 */
@SuppressWarnings("fallthrough")
static long parseFormDataContent(final InputStream postContent, final long maxLen, final Charset charset, final Map<String,String[]> map) throws IOException {
  final CharsetDecoder charsetDecoder = charset.newDecoder()
    .onMalformedInput(CodingErrorAction.REPORT)
    .onUnmappableCharacter(CodingErrorAction.REPORT);
  long len = 0L, keyPos = 0L, valuePos = 0L;
  final ByteArrayOutputStream2 keyStream = new ByteArrayOutputStream2(),
    valueStream = new ByteArrayOutputStream2();
  ByteArrayOutputStream2 currentStream = keyStream;
  for(;;) {
    int b = postContent.read();
    switch (b) {
      case -1: // end of stream
      case '&': // separator
        if (keyStream.size() > 0) {
          final String key = decodeChars(keyStream, keyPos, charsetDecoder), value = decodeChars(valueStream, valuePos, charsetDecoder);
          MultiMapSolrParams.addParam(key, value, map);
        } else if (valueStream.size() > 0) {
          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded invalid: missing key");
        }
        keyStream.reset();
        valueStream.reset();
        keyPos = valuePos = len + 1;
        currentStream = keyStream;
        break;
      case '+': // space replacement
        currentStream.write(' ');
        break;
      case '%': // escape
        final int upper = digit16(b = postContent.read());
        len++;
        final int lower = digit16(b = postContent.read());
        len++;
        currentStream.write(((upper << 4) + lower));
        break;
      case '=': // kv separator
        if (currentStream == keyStream) {
          valuePos = len + 1;
          currentStream = valueStream;
          break;
        }
        // fall-through
      default:
        currentStream.write(b);
    }
    if (b == -1) {
      break;
    }
    len++;
    if (len > maxLen) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded content exceeds upload limit of " + (maxLen/1024L) + " KB");
    }
  }
  return len;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:63,代码来源:SolrRequestParsers.java


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