使用图API的奇怪搜索逻辑

时间:2013-04-28 15:17:40

标签: json facebook http facebook-graph-api

一直在使用搜索API,并在搜索结果中观察到一些奇特的结果。

我知道今天有一场切尔西足球比赛,所以我快速搜索切尔西在赛事中的相关内容:

(使用Graph API资源管理器@ https://developers.facebook.com/tools/explorer?

search?q=Chelsea&limit=5000&type=event&since=2013-04-28&until=2013-04-29

返回

{
  "data": [
    {
      "name": "Chelsea Jam Tree Comedy Competition Night", 
      "start_time": "2013-04-28T19:30:00+0100", 
      "timezone": "Europe/London", 
      "location": "The Jam Tree (Chelsea)", 
      "id": "201322573339969"
    }, 
    {
      "name": "Chelsea Basham at Fly By Night Club", 
      "start_time": "2013-04-27T19:00:00", 
      "end_time": "2013-04-27T22:00:00", 
      "location": "Fremantle, WA, AU", 
      "id": "119017388296997"
    }, 
    {
      "name": "The Chelsea & Alexis Show! with Special Friends", 
      "start_time": "2013-04-27T22:00:00-0400", 
      "timezone": "America/New_York", 
      "location": "Mark Fisher Fitness", 
      "id": "264038507064618"
    }
  ], 
  "paging": {
    "previous": "https://graph.facebook.com/search?q=Chelsea&limit=5000&since=1367173800&type=event&__paging_token=201322573339969", 
    "next": "https://graph.facebook.com/search?q=Chelsea&limit=5000&type=event&until=1367089200&__paging_token=119017388296997"
  }
}

好吧,不完全是我追求的 - 也许事件没有被添加/被公开。

但是 - 如果我搜索(注意'切尔西'之前的v)

search?q=v Chelsea&limit=5000&type=event&since=2013-04-28&until=2013-04-29
然后瞧 - 足球比赛了。

{
  "data": [
    {
      "name": "Man United v Chelsea", 
      "start_time": "2013-04-28T16:00:00+0100", 
      "timezone": "Europe/London", 
      "location": "The Rising Sun, Hazel Grove", 
      "id": "518842844847325"
    }, 
    {
      "name": "FOOTBALL, Chelsea V Swansea City", 
      "start_time": "2013-04-28T15:00:00+0100", 
      "timezone": "Europe/London", 
      "location": "White Hart, Barnby Dun", 
      "id": "590753400942611"
    }, 
    {
      "name": "Chelsea V Swansea City", 
      "start_time": "2013-04-28T15:00:00+0100", 
      "timezone": "Europe/London", 
      "location": "Lizard Lounge - South Woodford", 
      "id": "281525378649440"
    }, 
    {
      "name": "Chelsea FC v Swansea", 
      "start_time": "2013-04-28T10:00:00-0400", 
      "end_time": "2013-04-28T12:00:00-0400", 
      "timezone": "America/Toronto", 
      "location": "Scallywags", 
      "id": "516466885084282"
    }, 
    {
      "name": "Chelsea v Swansea", 
      "start_time": "2013-04-28T15:00:00+0100", 
      "timezone": "Europe/London", 
      "location": "Stamford Bridge", 
      "id": "152203718287492"
    }, 
    {
      "name": "Chelsea v Swansea", 
      "start_time": "2013-04-28T19:00:00+0500", 
      "timezone": "Asia/Baku", 
      "location": "Stamford bridge, Fulham road, Лондон", 
      "id": "649119368438501"
    }, 
    {
      "name": "Chelsea v Swansea", 
      "start_time": "2013-04-28T09:30:00-0400", 
      "end_time": "2013-04-28T12:30:00-0400", 
      "timezone": "America/New_York", 
      "location": "Ireland's Four Courts", 
      "id": "404696952971017"
    }
  ], 
  "paging": {
    "previous": "https://graph.facebook.com/search?q=v Chelsea&limit=5000&since=1367161200&type=event&__paging_token=518842844847325", 
    "next": "https://graph.facebook.com/search?q=v Chelsea&limit=5000&type=event&until=1367155800&__paging_token=404696952971017"
  }
}

API是否有问题,或者我做错了什么?

由于

1 个答案:

答案 0 :(得分:0)

这是预期的行为。搜索“A”并不意味着您可以获得包含“A”字符的所有结果。搜索“A”并不意味着您可以获得“Apple”。数据库太多,无法涵盖所有​​可能性。所以为了得到'切尔西V',你必须给'V'和'切尔西'关键字。否则它想要回归'切尔西球场','切尔西球员',以及所有可能性?不,服务器处理的结果太大了。