2012-09-16 58 views
0

評論搜索陣列當我拉從流表搜索結果,返回的組成部分之一是註釋的數組。我在想,如果有搜索基礎上的意見陣列中的註釋的文本的方法嗎?FQL - 在流

這是我的查詢。它工作正常,在其目前的形式:

 

    SELECT post_id, attribution, message, description, comments.comment_list.text, likes, 
    place, permalink, message_tags, message, description_tags, type 
    FROM stream WHERE filter_key in 
    (SELECT filter_key FROM stream_filter WHERE uid=me()) 
    AND 
    (
    (strpos(lower(message), 'college football') >= 0) OR 
    (strpos(lower(description), 'college football') >= 0) OR 
    (strpos(lower(attribution), 'college football') >= 0) 
    ) 
    order by created_time desc 

comments.comment_list.text結果返回的行之一是這樣的:

 

    "comments": { 
      "comment_list": [ 
      { 
       "text": "I love college football" 
      }, 
      { 
       "text": "Alabama and LSU rule college football" 
      } 
      ] 
    } 

我的問題是:有沒有辦法了我也在搜索comments.comment_list.text以與我爲消息描述歸屬以上?當我嘗試添加像下面這樣:

 

    (strpos(lower(comments.comment_list.text), 'college football') >= 0) 

我有一個空的數據集(有趣的是,我沒有得到任何錯誤,只是空的結果)。我明白爲什麼,因爲我需要以某種方式能夠通過註釋的數組迭代,然後檢索其文字和做註釋的文本進行比較。我想在Facebook上的一端與FQL要做到這一點,並想避免檢索所有結果,然後通過他們迭代在我結束。有關我如何能夠做到的任何想法或建議?

在此先感謝您的幫助!

回答

2

stream表中的comments字段僅檢索評論的子集。我認爲,限制爲5。也就是說,並通過FQL返回數組搜索好像它應該很容易。事實並非如此。

要做的最好的事情是將其轉換爲多查詢。你的結果,你會想看看只有#combined數據。

{'all_posts': 
    'SELECT post_id FROM stream WHERE filter_key in 
    (SELECT filter_key FROM stream_filter WHERE uid=me())', 
'commented': 
    'SELECT post_id FROM comment WHERE post_id IN (SELECT post_id FROM #all_posts) 
     AND (strpos(lower(text), 'college football') >= 0', 
'combined': 
    'SELECT post_id, attribution, message, description, comments.comment_list.text, likes, 
     place, permalink, message_tags, message, description_tags, type 
     FROM stream WHERE post_id IN (SELECT post_id FROM #all_posts) AND 
     (
     (strpos(lower(message), 'college football') >= 0) OR 
     (strpos(lower(description), 'college football') >= 0) OR 
     (strpos(lower(attribution), 'college football') >= 0) 
     ) 
    OR post_id IN (SELECT post_id FROM #commented) 
    order by created_time desc' 
}