Skip to content

Commit

Permalink
docs: update some out of date docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdh committed Sep 19, 2024
1 parent 301d90c commit 9602283
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions ckanext/versioned_datastore/lib/query/search/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,16 @@ def to_dsl(self) -> DSLQuery:
@staticmethod
def create_point_filter(distance, coordinates):
"""
Adds a point filter query to the search object and returns a new search object.
Creates an Elasticsearch Query object filtering for records within the radius of
the given point coordinates.
:param distance: the radius of the circle centred on the specified location
within which records must lie to be matched. This can be
specified in any form that elasticsearch accepts for distances
(see their doc, but essentially values like 10km etc).
:param coordinates: the point to centre the radius on, specified as a lon/lat
pair in a list (i.e. [40.2, -20]).
:return: a search object
:return: a Query object
"""
options = {
"distance": distance,
Expand All @@ -239,18 +240,18 @@ def create_point_filter(distance, coordinates):
@staticmethod
def create_multipolygon_filter(coordinates):
"""
Adds a multipolygon filter query to the search object and returns a new search
object. Only the first group in each polygon grouping will be used as
elasticsearch doesn't support this type of query yet (this kind of query is used
for vacating space inside a polygon, like a donut for example).
Creates a Query object for the given multipolygon filters. Only the first group
in each polygon grouping will be used as elasticsearch doesn't support this type
of query yet (this kind of query is used for vacating space inside a polygon,
like a donut for example).
If more than one group is included then they are included as an or with a
minimum must match of 1.
:param coordinates: a list of a list of a list of a list of at least 3 lon/lat
pairs (i.e. [[[[-16, 44], [-13.1, 34.8], [15.99, 35],
[5, 49]]]])
:return: a search object
:return: a Query object
"""
should = []
for group in coordinates:
Expand Down Expand Up @@ -283,34 +284,32 @@ def create_multipolygon_filter(coordinates):
@staticmethod
def create_polygon_filter(coordinates):
"""
Adds a polygon filter query to the search object and returns a new search
object. Only the first group in each polygon grouping will be used as
elasticsearch doesn't support this type of query yet (this kind of query is used
for vacating space inside a polygon, like a donut for example.
Creates a polygon Query object. Only the first group in each polygon grouping
will be used as elasticsearch doesn't support this type of query yet (this kind
of query is used for vacating space inside a polygon, like a donut for example.
If more than one group is included then they are included as an or with a
minimum must match of 1.
:param coordinates: a list of a list of a list of at least 3 lon/lat pairs (i.e.
[[[-16, 44], [-13.1, 34.8], [15.99, 35], [5, 49]]])
:return: a search object
:return: a Query object
"""
# just wrap in another list and pass to the multipolygon handler
return BasicQuery.create_multipolygon_filter([coordinates])

@staticmethod
def create_geo_filter(geo_filter):
"""
Updates the given search DSL object with the geo filter specified in the
geo_filter dict.
Creates a Query object for the geo filter specified in the geo_filter dict.
:param geo_filter: a dict describing a geographic filter. This should be a
GeoJSON geometry and should therefore include a type key and
a coordinates key. The type must be one of: Point,
MultiPolygon or Polygon. In the case of a Point, a distance
key is also required which specifies the radius of the point
in a form elasticsearch understands (for example, 10km).
:return: a search DSL object
:return: a Query object
"""
# we support 3 GeoJSON types currently, Point, MultiPolygon and Polygon
query_type_map = {
Expand Down

0 comments on commit 9602283

Please sign in to comment.