Geo or spatial searching for entities add invaluable location-aware potential to your applications. They allow you to fire queries like 'get restaurants near my house' or 'get hotel accommodations in Bangalore'. But they are difficult to implement as they bring with them a lot of trigonometry hell and indexing problems.
Appacitive provides you the ability to fire such queries out-of-the-box using a special property data type called geography.
The geography data type
A schema or relation property can be assigned the geography data type. This means that their articles or connections will contain geo coordinates as property values.
For example, a schema called restaurant could have a geography property called location. An article of this schema for Pizza Hut, Bangalore would have the value for location as 12.940155, 77.625262. These are the latitude and longitude coordinates of this location.
There are two kinds of spatial searches you can perform on geography data.
I. Radial Search
A radial search lets you search for points of interest in the vicinity of a specific point of interest.
The 'get restaurants near my house' is a good example when you know the location of your house.
GET https://apis.appacitive.com/article/restaurant/find/all?properties=(*location within_circle 12.940155, 77.625262 3 mi)
This query will fetch you a paginated list of all articles of schema restaurant with a property value for location in a 3 mile radius from 12.940155, 77.625262.
Note : The * before location depicts that location is a user defined property.
The mi stands for miles. You could instead use km instead for kilometers or m for meters. You can add more filters in this query to the same property or other properties or attributes.
II. Polygon Search
A polygon search allows you to search for points of interest (articles, connections or users) inside a polygon. If you have 3 or more coordinates and want to find articles or connections with geography property values that lie within those coordinates, you will use polygon search.
For example, 'get hotel accommodations in Bangalore' could be accomplished using the polygon search.
I need to know at least three coordinates that surround the city of Bangalore, and I can find all accommodations that fall inside the triangle those three coordinates make.
GET https://apis.appacitive.com/article/restaurant/find/all?properties=(*location within_polygon 0.0,0.0 | 10.0,0.0 | 0.0,10.0)
This will return a paginated list of all articles of schema restaurant which have a geography value for property location which lies inside the polygon formed by the coordinates 0.0,0.0 | 10.0,0.0 | 0.0,10.0.
So this way you can mix-n-match multiple filters on your queries like geo, pagination, sorting, between values, tags, free-text etc. to drill down on your data on Appacitive.