Support Topics Documentation Slack YouTube Blog

Search for geo points in all categories


(Bbhh) #1

I wish to get all points in a rectangular area regardless of category.

When querying, if I leave the categories parameter, search is performed on the Default category which in my app is empty.

I cannot just construct a concatenated string of all my categories. Currently a few dozen and eventually several hundred)

How can this be done?


(Kate Maksimenko) #2

Hi!
You can get all categories with request:

curl 
-H application-id:[url=http://backendless.com/documentation/geo/rest/obtaining_app_id.htm]application-id-value-from-console[/url]
-H secret-key:[url=http://backendless.com/documentation/geo/rest/obtaining_app_id.htm]secret-key-value-from-console[/url] 
-H application-type:REST 
-X GET 
-v http://api.backendless.com/v1/geo/categories

http://backendless.com/documentation/geo/rest/geo_retrieving_geo_categories.htm

And add them into search query, where categories separated by comma:
http://backendless.com/documentation/geo/rest/geo_search_in_a_rectangular_area.htm


(Bbhh) #3

Thanks I see it will work.

Is there a maximum limit on the number of categories you recommend? I would like to have hundreds of categories. With that the query URL will be very very long.


(Kate Maksimenko) #4

There are some standards\limits:

and here:

http://www.boutell.com/newfaq/misc/urllength.html

If you see limits on the our side - we can change them due to your demands.


(Mark Piller) #5

Hi Bbhh,

Out of curiosity, how do you intend to use categories in your application? What is the logical meaning of a category for you? Perhaps there is another way to group the geo points. For example, you could keep all the points in the same category and group them through a special metadata property. For instance “groupName=XXX”.

Cheers,

Mark


(Bbhh) #6

Hi Mark I would like to categorize for example by different types of offices, shops, restaurants, and more. Yes I agree it’s more proper to just have these less than a dozen categories, with relevant metadata such as law=immigration, fashion=hipster, resaturant=thai,

I was not planning the above because I was guessing
http://backendless.com/documentation/geo/rest/geo_relative_search.htm
is still in the works if I want to search category law with partial metadata law=immigration.

Thanks


(Mark Piller) #7

Hi Bbhh,

Relative search is supported, though the doc is missing. Based on what you described, I would recommend going with fewer categories and richer metadata. I think that would work much better for you.

In your searches you can reference as many metadata properties and express your queries in a SQL format (the where clause part). Please let me know if you need any help with the syntax for the geo queries. Something you could do is add geo points to Backendless and then use code generation for JavaScript to play with your own data. The generated project makes it very easy to introspect geo storage with queries and see how they work.

Regards,
Mark


(Bbhh) #8

Hi Mark

That’s wonderful perhaps I can be referred to an example of partial metadata search match with the REST api?

Regards


(Mark Piller) #9

Hi Bbhh,

When you say “partial metadata”, do you mean a search for only some metadata properties? If not, please clarify.

Here’s the doc for REST search requests in radius:
http://backendless.com/documentation/geo/rest/geo_radius_based_search.htm

and in rectangular area:
http://backendless.com/documentation/geo/rest/geo_search_in_a_rectangular_area.htm

The example in the latter performs a search for the following metadata:

{“Cuisine”:“French”, “Atmosphere”:“Romantic”}

curl -H application-id:application-id-value-from-console-H secret-key:secret-key-value-from-console -X GET -v “http://api.backendless.com/v1/geo/rect?nwlat=32.78&nwlon=-96.8&selat=25.79&selon=-80.22&categories=Restaurants&metadata={“Cuisine”%3A"French"%2C%20"Atmosphere"%3A"Romantic"}

Alternatively, you could use the SQL syntax to express metadata search:

Cuisine = ‘French’ and Atmosphere = ‘Romantic’

curl -H application-id:application-id-value-from-console-H secret-key:secret-key-value-from-console -X GET -v “http://api.backendless.com/v1/geo/rect?nwlat=32.78&nwlon=-96.8&selat=25.79&selon=-80.22&categories=Restaurants&where=Cuisine%20%3D%20’French’%20and%20Atmosphere%20%3D%20’Romantic’