~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to solr/core/src/java/org/apache/solr/request/LocalSolrQueryRequest.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
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
8
 
 *
9
 
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 
 *
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.
16
 
 */
17
 
 
18
 
package org.apache.solr.request;
19
 
 
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;
25
 
 
26
 
import java.util.Map;
27
 
import java.util.HashMap;
28
 
import java.util.Iterator;
29
 
 
30
 
// With the addition of SolrParams, this class isn't needed for much anymore... it's currently
31
 
// retained more for backward compatibility.
32
 
 
33
 
/**
34
 
 * @version $Id: LocalSolrQueryRequest.java 561900 2007-08-01 18:36:45Z ryan $
35
 
 */
36
 
public class LocalSolrQueryRequest extends SolrQueryRequestBase {
37
 
  public final static Map emptyArgs = new HashMap(0,1);
38
 
 
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()});
47
 
    }
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);
53
 
  }
54
 
 
55
 
  public LocalSolrQueryRequest(SolrCore core, String query, String qtype, int start, int limit, Map args) {
56
 
    super(core,makeParams(query,qtype,start,limit,args));
57
 
  }
58
 
 
59
 
  public LocalSolrQueryRequest(SolrCore core, NamedList args) {
60
 
    super(core, SolrParams.toSolrParams(args));
61
 
  }
62
 
 
63
 
  public LocalSolrQueryRequest(SolrCore core, Map<String,String[]> args) {
64
 
    super(core, new MultiMapSolrParams(args));
65
 
  }
66
 
  public LocalSolrQueryRequest(SolrCore core, SolrParams args) {
67
 
    super(core, args);
68
 
  }
69
 
 
70
 
}
71