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

« back to all changes in this revision

Viewing changes to solr/core/src/java/org/apache/solr/search/SpatialFilterQParserPlugin.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
 
package org.apache.solr.search;
2
 
/**
3
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
4
 
 * contributor license agreements.  See the NOTICE file distributed with
5
 
 * this work for additional information regarding copyright ownership.
6
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
7
 
 * (the "License"); you may not use this file except in compliance with
8
 
 * the License.  You may obtain a copy of the License at
9
 
 *
10
 
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 
 *
12
 
 * Unless required by applicable law or agreed to in writing, software
13
 
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 
 * See the License for the specific language governing permissions and
16
 
 * limitations under the License.
17
 
 */
18
 
 
19
 
import org.apache.solr.common.params.SolrParams;
20
 
import org.apache.solr.common.util.NamedList;
21
 
import org.apache.solr.request.SolrQueryRequest;
22
 
 
23
 
/**
24
 
 * Creates a spatial Filter based on the type of spatial point used.
25
 
 * <p/>
26
 
 * The field must implement {@link org.apache.solr.schema.SpatialQueryable}
27
 
 * <p/>
28
 
 * All units are in Kilometers
29
 
 * <p/>
30
 
 * <p/>
31
 
 * Syntax:
32
 
 * <pre>{!geofilt sfield=&lt;location_field&gt; pt=&lt;lat,lon&gt; d=&lt;distance&gt;}</pre>
33
 
 * <p/>
34
 
 * Parameters:
35
 
 * <ul>
36
 
 * <li>sfield - The field to filter on. Required.</li>
37
 
 * <li>pt - The point to use as a reference.  Must match the dimension of the field. Required.</li>
38
 
 * <li>d - The distance in km.  Requited.</li>
39
 
 * </ul>
40
 
 * The distance measure used currently depends on the FieldType.  LatLonType defaults to using haversine, PointType defaults to Euclidean (2-norm).
41
 
 *
42
 
 * <p/>
43
 
 * Examples:
44
 
 * <pre>fq={!geofilt sfield=store pt=10.312,-20.556 d=3.5}</pre>
45
 
 * <pre>fq={!geofilt sfield=store}&pt=10.312,-20&d=3.5</pre>
46
 
 * <pre>fq={!geofilt}&sfield=store&pt=10.312,-20&d=3.5</pre>
47
 
 * <p/>
48
 
 * Note: The geofilt for LatLonType is capable of also producing scores equal to the computed distance from the point
49
 
 * to the field, making it useful as a component of the main query or a boosting query.
50
 
 */
51
 
public class SpatialFilterQParserPlugin extends QParserPlugin {
52
 
  public static String NAME = "geofilt";
53
 
 
54
 
  @Override
55
 
  public QParser createParser(String qstr, SolrParams localParams,
56
 
                              SolrParams params, SolrQueryRequest req) {
57
 
 
58
 
    return new SpatialFilterQParser(qstr, localParams, params, req, false);
59
 
  }
60
 
 
61
 
  public void init(NamedList args) {
62
 
 
63
 
  }
64
 
 
65
 
}
66