FQL query through category_list

六月ゝ 毕业季﹏ 提交于 2019-12-22 00:06:07

问题


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 a RESTAURANT/CAFE.


来源:https://stackoverflow.com/questions/15722538/fql-query-through-category-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!