1

我已经构建了以下 FQL 查询,但在添加过滤器时遇到了问题。

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)

问题是我只想要与餐厅相关的页面。我想我可以通过页表中的“类别”对其进行过滤,但我不知道要使用哪种方法。

我怎样才能做到这一点?关于我可以使用的可用方法的文档在哪里(例如 categories.contains("Restaurant"))

谢谢!

4

1 回答 1

2

您要查找的内容包含在该type字段中。你写了TYPE,那是错误的。

type(字符串):页面的类型。例如产品/服务、计算机/技术

你需要做:

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"

... 只为您提供餐厅:

"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.
于 2013-03-31T00:50:46.640 回答