Query
Ganos supports property, ID, and spatiotemporal range queries. This topic describes the available query methods.
Configuration parameter | Description |
URL | /index/:alias/:index/features |
Method | GET |
URL parameters | alias=[alphanumeric]: The name of the data source (DS). index=[alphanumeric]: The name of the index. q=[alphanumeric]: The query conditions in JSON format. |
Success information | Code: 200 Content: A feature collection in GeoJSON format. |
Failure information | Code: 400: A required parameter was not specified. Content: empty. |
curl\
'localhost:8080/geoserver/geomesa/geojson/index/:alias/:index/features' \
--get --data-urlencode 'q=Query conditions in JSON format'HBase Ganos supports the following property query predicates:
Configuration parameter | Description |
$lt | Less than |
$lte | Less than or equal to |
$gt | Greater than |
$gte | Greater than or equal to |
The following sections describe common query methods:
(1) Property query. HBase Ganos uses predicate operations for property queries.
Example 1: Query for the feature where id = 0.
curl \
'localhost:8080/geoserver/geomesa/geojson/index/my_ds/test/features' \
--get --data-urlencode \
'q={
"properties.id":"0"
}'Example 2: Query for the feature where name = n1.
curl \
'localhost:8080/geoserver/geomesa/geojson/index/my_ds/test/features' \
--get --data-urlencode \
'q={"properties.name":"n1"}'Example 3: Query for all features where age is less than 30.
curl \
'localhost:8080/geoserver/geomesa/geojson/index/my_ds/test/features' \
--get --data-urlencode \
'q={"properties.age":{"$lt":30}}'(2) Spatial query
Example 1: Query using a bounding box (BBOX).
q={
"geometry" :
{
"$bbox" : [-180, -90, 180, 90]
}
}Example 2: Spatial intersection query.
q={
"geometry" : {
"$intersects" : {
"$geometry" : {
"type" : "Point",
"coordinates" : [30, 10]
}
}
}
}Example 3: Spatial within query.
q={
"geometry" : {
"$within" : { "$geometry" : {
"type" : "Polygon",
"coordinates": [ [ [0,0], [3,6], [6,1], [0,0] ] ]
}}
}
}Example 4: Spatial contains query.
q={
"geometry" : {
"$contains" : {
"$geometry" : {
"type" : "Point",
"coordinates" : [30, 10]
}
}
}
}(3) Time query
Example 1: Use the $during predicate to specify a time range.
curl \
'localhost:8080/geoserver/geomesa/geojson/index/myds/test/features' \
--get --data-urlencode \
'q={"dtg":{"$during":"2018-01-02T08:00:00Z/2018-03-02T10:00:00Z"}}'Example 2: Use $lt, $gt, $lte, and $gte.
curl \ 'localhost:8080/geoserver/geomesa/geojson/index/myds/test/features' \
--get --data-urlencode \
'q={"dtg":{"$lt" : "2013-01-02 00:00:00"}}'(4) Combined query
AND: Create the query condition a = 5 AND b = 6.
{ "a" : 5, "b" : 6 }OR: Combines query conditions, such as a=5 OR a=6.
{ "$or" : [ { "a" : 5 }, { "b" : 6 } ] }Example: Combine a spatiotemporal query with a property query.
curl /
'http://localhost:8080/geoserver/geomesa/geojson/index/tdrive_ds/tdrive_index/featu res'
--get --data-urlencode \
'q={
"geometry":{"$bbox":[116.3383,39.8291,116.3384,39.8292]},
"properties.taxi_num":"1131",
"properties.dtg":{"$gt" : "2008-02-08T08:00:00.000+0000"},
"properties.dtg":{"$lt" : "2008-02-08T12:21:16.000+0000"}
}'