0

当我从流表中提取搜索结果时,返回的组件之一是一组注释。我想知道是否有任何基于评论数组中评论文本的搜索方式?

这是我的查询。它以目前的形式运行良好:

    选择 post_id、属性、消息、描述、comments.comment_list.text、喜欢、
     地点、固定链接、message_tags、message、description_tags、类型
    FROM stream WHERE filter_key in
    (SELECT filter_key FROM stream_filter WHERE uid=me())
    和
    (
    (strpos(lower(message), '大学橄榄球') >= 0) 或
    (strpos(lower(description), '大学橄榄球') >= 0) 或
    (strpos(lower(attribution), '大学橄榄球') >= 0)
    )
    按 created_time 顺序排序

返回的行之一的comments.comment_list.text结果如下所示:

    “注释”: {
            “评论列表”:[
             {
                “文本”:“我喜欢大学橄榄球”
             },
             {
                "text": "阿拉巴马州和路易斯安那州立大学统治大学橄榄球"
             }
             ]
    }

我的问题是:我有什么方法可以像上面搜索messagedescriptionattribution一样在comments.comment_list.text中搜索?当我尝试添加以下内容时:

    (strpos(lower(comments.comment_list.text), '大学橄榄球') >= 0)

我得到了一个空数据集(有趣的是,我没有得到任何错误,只是空结果)。我明白为什么,因为我需要以某种方式遍历评论数组,然后检索他们的文本并对评论的文本进行比较。我想在 Facebook 端使用 FQL 执行此操作,并希望避免检索所有结果然后在我端迭代它们。关于我如何能够做到这一点的任何想法或建议?

在此先感谢您的帮助!

4

1 回答 1

2

表中的comments字段stream仅检索评论的子集。我认为限制是 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'
}
于 2012-09-17T12:53:52.510 回答