1
package org.apache.solr.search;
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
10
* http://www.apache.org/licenses/LICENSE-2.0
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.
19
import org.apache.solr.common.params.SolrParams;
20
import org.apache.solr.common.util.NamedList;
21
import org.apache.solr.request.SolrQueryRequest;
24
* Creates a spatial Filter based on the type of spatial point used.
26
* The field must implement {@link org.apache.solr.schema.SpatialQueryable}
28
* All units are in Kilometers
32
* <pre>{!geofilt sfield=<location_field> pt=<lat,lon> d=<distance>}</pre>
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>
40
* The distance measure used currently depends on the FieldType. LatLonType defaults to using haversine, PointType defaults to Euclidean (2-norm).
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>
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.
51
public class SpatialFilterQParserPlugin extends QParserPlugin {
52
public static String NAME = "geofilt";
55
public QParser createParser(String qstr, SolrParams localParams,
56
SolrParams params, SolrQueryRequest req) {
58
return new SpatialFilterQParser(qstr, localParams, params, req, false);
61
public void init(NamedList args) {