Spatial view does not allow me to put any string value. This means, I have no way to query (either N1QL or view) geo location and other string values in one shot, right?
Strongly recommend to add GeoSpatial Function to N1QL. None of the Spatial query condition looks simple. I have handle cross180degree case plus some long trigonometry formula.
select name, geo, city, (ACOS(SIN(PI()* geo.lat/180.0)*SIN(PI()*37.7/180.0)+COS(PI()*geo.lat/180.0)*
COS(PI()*37.7/180.0)*COS(PI()*-122.33/180.0-PI()*geo.lon/180.0))*6371) as distance
from `beer-sample` b
WHERE type = 'brewery' AND
(ACOS(SIN(PI()* geo.lat/180.0)*SIN(PI()*37.7/180.0)+COS(PI()*geo.lat/180.0)*
COS(PI()*37.7/180.0)*COS(PI()*-122.33/180.0-PI()*geo.lon/180.0))*6371) < 10
and state = 'California'
order by distance asc;
You can try this on beer-sample yourself. While this exploits the index on type and state, it still can’t use any index for the spatial index.
Spatial indices use bounding boxes to find the nearest qualifying locations.
This case is a post scan filter…