2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.solr.request;
20
import org.apache.solr.common.params.CommonParams;
21
import org.apache.solr.common.params.MultiMapSolrParams;
22
import org.apache.solr.common.params.SolrParams;
23
import org.apache.solr.common.util.NamedList;
24
import org.apache.solr.core.SolrCore;
27
import java.util.HashMap;
28
import java.util.Iterator;
30
// With the addition of SolrParams, this class isn't needed for much anymore... it's currently
31
// retained more for backward compatibility.
34
* @version $Id: LocalSolrQueryRequest.java 561900 2007-08-01 18:36:45Z ryan $
36
public class LocalSolrQueryRequest extends SolrQueryRequestBase {
37
public final static Map emptyArgs = new HashMap(0,1);
39
protected static SolrParams makeParams(String query, String qtype, int start, int limit, Map args) {
40
Map<String,String[]> map = new HashMap<String,String[]>();
41
for (Iterator iter = args.entrySet().iterator(); iter.hasNext();) {
42
Map.Entry e = (Map.Entry)iter.next();
43
String k = e.getKey().toString();
44
Object v = e.getValue();
45
if (v instanceof String[]) map.put(k,(String[])v);
46
else map.put(k,new String[]{v.toString()});
48
if (query!=null) map.put(CommonParams.Q, new String[]{query});
49
if (qtype!=null) map.put(CommonParams.QT, new String[]{qtype});
50
map.put(CommonParams.START, new String[]{Integer.toString(start)});
51
map.put(CommonParams.ROWS, new String[]{Integer.toString(limit)});
52
return new MultiMapSolrParams(map);
55
public LocalSolrQueryRequest(SolrCore core, String query, String qtype, int start, int limit, Map args) {
56
super(core,makeParams(query,qtype,start,limit,args));
59
public LocalSolrQueryRequest(SolrCore core, NamedList args) {
60
super(core, SolrParams.toSolrParams(args));
63
public LocalSolrQueryRequest(SolrCore core, Map<String,String[]> args) {
64
super(core, new MultiMapSolrParams(args));
66
public LocalSolrQueryRequest(SolrCore core, SolrParams args) {