问题
I've built the following FQL query but I'm facing problems to add a filter.
SELECT
about,
attire,
categories,
checkins,
company_overview,
culinary_team,
description,
fan_count,
food_styles,
founded,
general_info,
general_manager,
hours,
keywords,
location,
mission,
name,
page_id,
page_url,
parent_page,
parking,
payment_options,
phone,
price_range,
products,
public_transit,
restaurant_services,
restaurant_specialties,
talking_about_count,
TYPE,
username,
website,
were_here_count,
pic
FROM page
WHERE page_id IN
(SELECT
page_id,
latitude,
longitude
FROM place
WHERE distance(latitude, longitude, '-30.03852', '-51.17877') < 50000
LIMIT 10)
The problem is that I just want the pages related to Restaurants. I think I can filter it through "categories" at page table but I don't know wich methods to use.
How can I do this? Where is the documentation about the available methods that I can use (something like categories.contains("Restaurant"))
Thanks!
回答1:
What you are looking for is included in the type
field. You wrote TYPE
and that is wrong.
type (string): The type of Page. e.g. Product/Service, Computers/Technology
You would need to do:
SELECT page_id, type, categories
FROM page
WHERE page_id IN
(SELECT
page_id,
latitude,
longitude
FROM place
WHERE distance(latitude, longitude, '-30.03852', '-51.17877') < 50000
LIMIT 100)
AND type="RESTAURANT/CAFE"
... gives you restaurants only:
"data": [
{
"page_id": 202457279801080,
"type": "RESTAURANT/CAFE",
"categories": [
{
"id": 185459711490789,
"name": "Brazilian Restaurant"
},
{
"id": 168976549819329,
"name": "French Restaurant"
},
{
"id": 163300367054197,
"name": "Seafood Restaurant"
}
]
},
Problem is that in many cases, the type
field isn't set by page owners... so you are going to pass by entries which are restaurants:
"data": [
{
"page_id": 216824565018619,
"type": "LOCAL BUSINESS",
"categories": [
{
"id": 134501539950711,
"name": "Sushi Restaurant"
}
]
}
I don't even know where these categories come from and how to set them. In my opinion, this field was used before and is now deprecated. Facebook kept the field so that every page keeps displaying this information.
According to this post, you can't filter categories through an FQL query.
I suggest you to request all the places around using your actual request and to make your own filtering by checking:
- whether one of the categories contains keywords related to restaurants:
restaurant
,bar
,steakhouse
, etc., - OR the
type
of the place is aRESTAURANT/CAFE
.
来源:https://stackoverflow.com/questions/15722538/fql-query-through-category-list