HBase Ganos supports various queries such as the attribute query, ID query, and spatio-temporal range query. You can query data in the following ways:

URL /index/:ds/:index/features
Method GET
URL parameters Required: alias=[alpha numeric] ds name index=[alpha numeric] index name optional: query condition indicated by q=[alpha numeric] JSON
Success response Code: 200. Content: The Feature collection in the GeoJSON format.
Error response Code: 400, which indicates that some required parameters are not specified. Content: empty.
curl\ 
'localhost:8080/geoserver/geomesa/geojson/index/:alias/:index/features' \    --get --data-urlencode 'q=query conditions in JSON format'
		

The following table lists the predicates supported by HBase Ganos for attribute queries.

$lt Less than
$lte Less than or equal to
$gt Greater than
$gte Greater than or equal to

The following sections list several ways to query data:

1. Attribute queries. HBase Ganos attribute queries are performed by using predicates:

Example 1: Query features by using the id=0 condition.

curl \ 
'localhost:8080/geoserver/geomesa/geojson/index/my_ds/my_index/features'\ 
--get --data-urlencode 
'q={
    "properties.id":"0"
 }'
		

Example 2: Query features by using the name=n1 condition.

curl \ 
'localhost:8080/geoserver/geomesa/geojson/index/my_ds/my_index/features'\ 
--get --data-urlencode 
'q={"properties.name":"n1"}'
		

Example 3: Query features by using the age<30 condition.

curl \ 
'localhost:8080/geoserver/geomesa/geojson/index/my_ds/my_index/features'\ 
--get --data-urlencode 
'q={"properties.age":{"$lt":30}}'
		

2. Spatial queries

Example 1: Query features by using the bounding box (BBOX).

q={ 
    "geometry": { 
    { 
        "$bbox" : [-180, -90, 180, 90] 
    }
}
		

Example 2: Query features by using the INTERSECTS predicate.

q={
    "geometry": {
        "$intersects" : {
            "geometry": { 
                "type": "Point", 
                "coordinates" : [30, 10] 
            }
        }
     }
}
		

Example 3: Query features by using the WITHIN predicate.

q={
    "geometry": {
        "$within" : { "$geometry" : {
            "type": "Polygon"
            "coordinates": [ [ [0,0], [3,6], [6,1], [0,0] ] ] 
        }}
     } 
}
		

Example 4: Query features by using the CONTAINS predicate.

q={
    "geometry": {
        "$contains" : {
            "geometry": { 
                "type": "Point", 
                "coordinates" : [30, 10] 
            }
        } 
    }
}
		

3. Time queries

Example 1: Use the $during predicates to specify a time period.

curl \
'localhost:8080/geoserver/geomesa/geojson/index/my_ds/my_index/features'\ 
--get --data-urlencode 
'q={"dtg":{"$during":"2018-01-02T08:00:00Z/2018-03-02T10:00:00Z"}}'

		

Example 2: Use the $lt(), $gt, $lte, and $gte predicates to specify a time period.

curl \ 'localhost:8080/geoserver/geomesa/geojson/index/my_ds/my_index'\ 
--get --data-urlencode 
'q={"dtg":{"$lt" : "2013-01-02 00:00:00"}}'
		

4. Combination queries

AND: specify the a = 5 and b = 6 condition in the statement.

{ "a" : 5, "b" : 6 }
		

OR: specify the a = 5 or a = 6 condition in the statement.

{ "$or" : [ { "a" : 5 }, { "b" : 6 } ] }
		

Example 1: Perform a spatio-temporal query together with an attribute query:

curl /
'localhost:8080/geoserver/geomesa/geojson/index/my_ds/my_index/features'\
--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"}
}'