How to use filter type geoWithinRadius and sample data for geoWithinRadius


#1

//Primary Index CREATE MAPVALUES INDEX my_geo_radius_Keys ON test.demo (points) GEO2DSPHERE //inserting the data var key = new Aerospike.Key(‘test’, ‘demo’, ‘foo6’) var bins = {points:{“type”: “polygons”, “coordinates”: [28.5705995, 77.2363587]}}; var metadata = { ttl: 100000 }

  client.put(key, bins, metadata, function (error) {
    assertOk(error, 'Writing database record')
    client.get(key, function (error, record, meta) {
      assertOk(error, 'Reading database record')
      //client.index_list_create('test', 'demo', 'points', Aerospike.INDEX_GEO2DSPHERE, 'demo_point_nidx');
      console.log(record, meta);
      //res.send(record);
    })
  })
  var key = new Aerospike.Key('test', 'demo', 'foo7')
  var bins = {points:{"type": "polygons", "coordinates": [28.6888393, 77.2674795]}};
  var metadata = { ttl: 100000 }

  client.put(key, bins, metadata, function (error) {
    assertOk(error, 'Writing database record')
    client.get(key, function (error, record, meta) {
      assertOk(error, 'Reading database record')
      //client.index_list_create('test', 'demo', 'points', Aerospike.INDEX_GEO2DSPHERE, 'demo_point_nidx');
      console.log(record, meta);
      //res.send(record);
    })
  })

//fetching the Data. var Aerospike = require(‘aerospike’); Aerospike.connect(sails.config.connections.aerospike, function (error, client) { var query=client.query(‘test’, ‘demo’); //query.select(‘name’); //query.where(Aerospike.filter.range(‘PK’, 1, 2)) query.where(Aerospike.filter.geoWithinRadius(‘points’, Aerospike.client.my_geo_radius_Keys, 28.55531, 77.2420009, 10000)); //query.where(Aerospike.filter.contains(‘emails’, ‘bob@email1.com’)) var stream = query.foreach(); stream.on(‘data’, function (record) { console.log(‘record =>’,record); //res.json(record); }) stream.on(‘error’, function (error) { console.log(‘error =>’,error); //res.json(error); }) stream.on(‘end’, function () { console.log(‘end’); //res.json(‘end’); }) res.json(‘end’); });

OutPut: { code: 4, message: ‘AEROSPIKE_ERR_REQUEST_INVALID’, func: ‘as_query_parse_records_async’, file: ‘src/main/aerospike/aerospike_query.c’, line: 232 }


#2

The best place to look for additional info on an unexpected response is look on the aerospike.log