Is it a requirement that the long and lat for a geo search are stored under an object ? the sample describes the "Creating a Geospatial Index "
or can i map a separate field for lat and long ? Also if lets say i store lat and long under a field like geo, where or how do you define the fields or is there a naming requirement like lat and long ?
Hi @aponnath,
You can map any field (name)for indexing as searchable geo location points. Just that it needs to conform to any of the following standard formats.
Geo-point expressed as an object, with lat
and lon
keys.
Geo-point expressed as a string with the format: "lat,lon"
.
Geo-point expressed as a geohash.
Geo-point expressed as an array with the format: [ lon
, lat
]
etc.
so based on what you say it cant be 2 fields inside an object like this
{
"_id": "d16da12b-0c63-4e65-8dbc-8a9623dfa0be",
"_type": "Residential",
"Record": {
"ListingId": "F1802040",
"StandardStatus": "Closed",
"MLSAreaMajor": "610 - Burbank",
"Address": {
"City": "Burbank",
"StateOrProvince": "CA",
"PostalCode": 91506,
"Longitude": -118.31621200,
"Latitude": 34.16792800
}
}
}
if thats’ the case that sucks as i have about 1 million records i would have to mutate
If “Address” is the the geo field you want indexed, then yes.
lon
/lng
and lat
are the supported field names for longitude and latitude.