本文整理汇总了Java中org.apache.solr.common.params.MultiMapSolrParams类的典型用法代码示例。如果您正苦于以下问题:Java MultiMapSolrParams类的具体用法?Java MultiMapSolrParams怎么用?Java MultiMapSolrParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultiMapSolrParams类属于org.apache.solr.common.params包,在下文中一共展示了MultiMapSolrParams类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: addDoc
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
static void addDoc(String doc, String chain) throws Exception {
Map<String, String[]> params = new HashMap<>();
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });
SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(),
(SolrParams) mmparams) {
};
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
ArrayList<ContentStream> streams = new ArrayList<>(2);
streams.add(new ContentStreamBase.StringStream(doc));
req.setContentStreams(streams);
handler.handleRequestBody(req, new SolrQueryResponse());
req.close();
}
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:SignatureUpdateProcessorFactoryTest.java
示例3: addDoc
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
private void addDoc(String doc) throws Exception {
Map<String, String[]> params = new HashMap<>();
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
params.put(UpdateParams.UPDATE_CHAIN, new String[] { "uniq-fields" });
SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(),
(SolrParams) mmparams) {
};
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
ArrayList<ContentStream> streams = new ArrayList<>(2);
streams.add(new ContentStreamBase.StringStream(doc));
req.setContentStreams(streams);
handler.handleRequestBody(req, new SolrQueryResponse());
req.close();
}
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:UniqFieldsUpdateProcessorFactoryTest.java
示例4: addDoc
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
static void addDoc(String doc, String chain) throws Exception {
Map<String, String[]> params = new HashMap<String, String[]>();
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });
SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(),
(SolrParams) mmparams) {
};
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
ArrayList<ContentStream> streams = new ArrayList<ContentStream>(2);
streams.add(new ContentStreamBase.StringStream(doc));
req.setContentStreams(streams);
handler.handleRequestBody(req, new SolrQueryResponse());
req.close();
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:SignatureUpdateProcessorFactoryTest.java
示例5: addDoc
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
private void addDoc(String doc) throws Exception {
Map<String, String[]> params = new HashMap<String, String[]>();
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
params.put(UpdateParams.UPDATE_CHAIN, new String[] { "uniq-fields" });
SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(),
(SolrParams) mmparams) {
};
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
ArrayList<ContentStream> streams = new ArrayList<ContentStream>(2);
streams.add(new ContentStreamBase.StringStream(doc));
req.setContentStreams(streams);
handler.handleRequestBody(req, new SolrQueryResponse());
req.close();
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:UniqFieldsUpdateProcessorFactoryTest.java
示例6: addDoc
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
private void addDoc(String chain, String doc) throws Exception {
Map<String, String[]> params = new HashMap<>();
params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), (SolrParams) mmparams) {
};
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
ArrayList<ContentStream> streams = new ArrayList<>(2);
streams.add(new ContentStreamBase.StringStream(doc));
req.setContentStreams(streams);
handler.handleRequestBody(req, new SolrQueryResponse());
}
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:UIMAUpdateRequestProcessorTest.java
示例7: makeParams
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
protected static SolrParams makeParams(String query, String qtype, int start, int limit, Map args) {
Map<String,String[]> map = new HashMap<>();
for (Iterator iter = args.entrySet().iterator(); iter.hasNext();) {
Map.Entry e = (Map.Entry)iter.next();
String k = e.getKey().toString();
Object v = e.getValue();
if (v instanceof String[]) map.put(k,(String[])v);
else map.put(k,new String[]{v.toString()});
}
if (query!=null) map.put(CommonParams.Q, new String[]{query});
if (qtype!=null) map.put(CommonParams.QT, new String[]{qtype});
map.put(CommonParams.START, new String[]{Integer.toString(start)});
map.put(CommonParams.ROWS, new String[]{Integer.toString(limit)});
return new MultiMapSolrParams(map);
}
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:LocalSolrQueryRequest.java
示例8: 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
示例9: 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
示例10: handleRequestBody
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的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
示例11: addDoc
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
private void addDoc(String chain, String doc) throws Exception {
Map<String, String[]> params = new HashMap<String, String[]>();
params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), (SolrParams) mmparams) {
};
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
ArrayList<ContentStream> streams = new ArrayList<ContentStream>(2);
streams.add(new ContentStreamBase.StringStream(doc));
req.setContentStreams(streams);
handler.handleRequestBody(req, new SolrQueryResponse());
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:15,代码来源:UIMAUpdateRequestProcessorTest.java
示例12: makeParams
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
protected static SolrParams makeParams(String query, String qtype, int start, int limit, Map args) {
Map<String,String[]> map = new HashMap<String,String[]>();
for (Iterator iter = args.entrySet().iterator(); iter.hasNext();) {
Map.Entry e = (Map.Entry)iter.next();
String k = e.getKey().toString();
Object v = e.getValue();
if (v instanceof String[]) map.put(k,(String[])v);
else map.put(k,new String[]{v.toString()});
}
if (query!=null) map.put(CommonParams.Q, new String[]{query});
if (qtype!=null) map.put(CommonParams.QT, new String[]{qtype});
map.put(CommonParams.START, new String[]{Integer.toString(start)});
map.put(CommonParams.ROWS, new String[]{Integer.toString(limit)});
return new MultiMapSolrParams(map);
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:16,代码来源:LocalSolrQueryRequest.java
示例13: 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
示例14: addDoc
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
static void addDoc(String doc, String chain) throws Exception {
Map<String, String[]> params = new HashMap<>();
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });
SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), mmparams) {
};
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
ArrayList<ContentStream> streams = new ArrayList<>(2);
streams.add(new ContentStreamBase.StringStream(doc));
req.setContentStreams(streams);
handler.handleRequestBody(req, new SolrQueryResponse());
req.close();
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:16,代码来源:OntologyUpdateProcessorFactoryTest.java
示例15: setParam
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
/**
* Insures that the given param is included in the query with the given value.
*
* <ol>
* <li>If the param is already included with the given value, the request is returned unchanged.</li>
* <li>If the param is not already included, it is added with the given value.</li>
* <li>If the param is already included, but with a different value, the value is replaced with the given value.</li>
* <li>If the param is already included multiple times, they are replaced with a single param with given value.</li>
* </ol>
*
* The passed-in valueToSet should NOT be URL encoded, as it will be URL encoded by this method.
*
* @param query The query portion of a request URL, e.g. "wt=json&indent=on&fl=id,_version_"
* @param paramToSet The parameter name to insure the presence of in the returned request
* @param valueToSet The parameter value to insure in the returned request
* @return The query with the given param set to the given value
*/
private static String setParam(String query, String paramToSet, String valueToSet) {
if (null == valueToSet) {
valueToSet = "";
}
try {
StringBuilder builder = new StringBuilder();
if (null == query || query.trim().isEmpty()) {
// empty query -> return "paramToSet=valueToSet"
builder.append(paramToSet);
builder.append('=');
StrUtils.partialURLEncodeVal(builder, valueToSet);
return builder.toString();
}
MultiMapSolrParams requestParams = SolrRequestParsers.parseQueryString(query);
String[] values = requestParams.getParams(paramToSet);
if (null == values) {
// paramToSet isn't present in the request -> append "¶mToSet=valueToSet"
builder.append(query);
builder.append('&');
builder.append(paramToSet);
builder.append('=');
StrUtils.partialURLEncodeVal(builder, valueToSet);
return builder.toString();
}
if (1 == values.length && valueToSet.equals(values[0])) {
// paramToSet=valueToSet is already in the query - just return the query as-is.
return query;
}
// More than one value for paramToSet on the request, or paramToSet's value is not valueToSet
// -> rebuild the query
boolean isFirst = true;
for (Map.Entry<String,String[]> entry : requestParams.getMap().entrySet()) {
String key = entry.getKey();
String[] valarr = entry.getValue();
if ( ! key.equals(paramToSet)) {
for (String val : valarr) {
builder.append(isFirst ? "" : '&');
isFirst = false;
builder.append(key);
builder.append('=');
StrUtils.partialURLEncodeVal(builder, null == val ? "" : val);
}
}
}
builder.append(isFirst ? "" : '&');
builder.append(paramToSet);
builder.append('=');
StrUtils.partialURLEncodeVal(builder, valueToSet);
return builder.toString();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:europeana,项目名称:search,代码行数:72,代码来源:RestTestBase.java
示例16: LocalSolrQueryRequest
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
public LocalSolrQueryRequest(SolrCore core, Map<String,String[]> args) {
super(core, new MultiMapSolrParams(args));
}
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:LocalSolrQueryRequest.java
示例17: parseQueryString
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
/**
* Given a url-encoded query string (UTF-8), map it into solr params
*/
public static MultiMapSolrParams parseQueryString(String queryString) {
Map<String,String[]> map = new HashMap<>();
parseQueryString(queryString, map);
return new MultiMapSolrParams(map);
}
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:SolrRequestParsers.java
示例18: testStreamBody
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
@Test
public void testStreamBody() throws Exception
{
String body1 = "AMANAPLANPANAMA";
String body2 = "qwertasdfgzxcvb";
String body3 = "1234567890";
SolrCore core = h.getCore();
Map<String,String[]> args = new HashMap<>();
args.put( CommonParams.STREAM_BODY, new String[] {body1} );
// Make sure it got a single stream in and out ok
List<ContentStream> streams = new ArrayList<>();
SolrQueryRequest req = parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
assertEquals( 1, streams.size() );
assertEquals( body1, IOUtils.toString( streams.get(0).getReader() ) );
req.close();
// Now add three and make sure they come out ok
streams = new ArrayList<>();
args.put( CommonParams.STREAM_BODY, new String[] {body1,body2,body3} );
req = parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
assertEquals( 3, streams.size() );
ArrayList<String> input = new ArrayList<>();
ArrayList<String> output = new ArrayList<>();
input.add( body1 );
input.add( body2 );
input.add( body3 );
output.add( IOUtils.toString( streams.get(0).getReader() ) );
output.add( IOUtils.toString( streams.get(1).getReader() ) );
output.add( IOUtils.toString( streams.get(2).getReader() ) );
// sort them so the output is consistent
Collections.sort( input );
Collections.sort( output );
assertEquals( input.toString(), output.toString() );
req.close();
// set the contentType and make sure tat gets set
String ctype = "text/xxx";
streams = new ArrayList<>();
args.put( CommonParams.STREAM_CONTENTTYPE, new String[] {ctype} );
req = parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
for( ContentStream s : streams ) {
assertEquals( ctype, s.getContentType() );
}
req.close();
}
开发者ID:europeana,项目名称:search,代码行数:49,代码来源:SolrRequestParserTest.java
示例19: SolrServletRequest
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
public SolrServletRequest(SolrCore core, HttpServletRequest req)
{
super(core, new MultiMapSolrParams(Collections.<String, String[]> emptyMap()));
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:5,代码来源:AlfrescoCoreAdminTester.java
示例20: parseQueryString
import org.apache.solr.common.params.MultiMapSolrParams; //导入依赖的package包/类
/**
* Given a url-encoded query string (UTF-8), map it into solr params
*/
public static MultiMapSolrParams parseQueryString(String queryString) {
Map<String,String[]> map = new HashMap<String, String[]>();
parseQueryString(queryString, map);
return new MultiMapSolrParams(map);
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:9,代码来源:SolrRequestParsers.java
注:本文中的org.apache.solr.common.params.MultiMapSolrParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论