I am trying to search documents using geospatial index of cloudant. Besides I have been using cloudant java client as below. But I cannot find the way or samples to search documents. Please Help Me!!
<dependency>
<groupId>com.cloudant</groupId>
<artifactId>cloudant-client</artifactId>
<version>2.12.0</version>
</dependency>
This is the geospacial index.
_design/eventgeo
indexname:st_index
function (doc) {
if (doc.geometry && doc.geometry.coordinates) {
st_index(doc.geometry);
}
}
Im trying to search the documents as below. but I get error:
Exception message:404 Object Not Found at https://??????.cloudant.com:443/events/_design/eventgeo/_search/_geo?limit=10&include_docs=true&q=lat:150.78688%20and%20lon:38.67915%20and%20radius:10000%20and%20relation:contains%20and%20include_docs:true. Error: not_found. Reason: _geo not found..
List<Event> events = this.database.search("eventgeo/_geo/st_index").limit(10).includeDocs(true)
.query("lat:" + latitude + " and lon:" + longitude + " and radius:" + 10000 + " and relation:contains"
+ " and include_docs:true", Event.class);
Take a look at the Cloudant documentation for geospatial queries: https://console.bluemix.net/docs/services/Cloudant/api/cloudant-geo.html#cloudant-nosql-db-geospatial
You appear to be using the search API endpoint:
_design/eventgeo/_search/_geo
I believe you want to use the geospatial indexing API endpoint instead:
_design/eventgeo/_geo/geoidx