Facebook fql 搜索页面与 strpos 不起作用?
为什么这个查询:
SELECT name, page_id from page WHERE strpos(lower(name),lower('coca')) >= 0
返回这个错误
"error_code": 604, "error_msg": "您的语句不可索引。 WHERE 子句必须包含可索引列。这样的列是 链接表中标有* http://developers.facebook.com/docs/reference/fql "
” Fql 文档是这样写的: page_id
& name
字段是可索引的
,为什么这个查询有效?我知道这不在页表上,而是
SELECT name
FROM user
WHERE uid IN (
SELECT uid2
FROM friend
WHERE uid1=me()
)
AND strpos(lower(name),"jo") >=0
Why this query :
SELECT name, page_id from page WHERE strpos(lower(name),lower('coca')) >= 0
returning this error
"error_code": 604, "error_msg": "Your statement is not indexable.
The WHERE clause must contain an indexable column. Such columns are
marked with * in the tables linked from
http://developers.facebook.com/docs/reference/fql "
Yet in the Fql doc is write that:page_id
& name
fields are Indexables
and why this Query works? I know that isn't on page table but
SELECT name
FROM user
WHERE uid IN (
SELECT uid2
FROM friend
WHERE uid1=me()
)
AND strpos(lower(name),"jo") >=0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不能在
WHERE
子句中使用 FQL 函数。这样做意味着数据库必须对表中的每一行进行计算,而不是使用索引,在 Facebook 的情况下,索引是一个相当大的数据库,需要遍历每一行......You can't use FQL functions in the
WHERE
clause. Doing so means the database would have to do a calculation on every row in the table instead of using the index, which in Facebook's case is a pretty large database to be going through every row...strpos 的用法WHERE 子句中的较低运算符使它们不可索引。
在上面的示例中:
它之所以有效,是因为您使用了可索引字段uid。
您可以使用 strpos & 降低您已有的可索引字段数据的某些子集。
在您的示例中,您没有可索引字段,因此会显示错误。
您可以使用 Graph API 获得相同的结果,如下所示:
Usage of strpos & lower operators in WHERE clause makes them not indexable.
In the example above:
It works because you use the indexable field uid.
You can use strpos & lower on some subset of data you already have with indexable field.
In your example you don't have indexable field so the error is showing.
You can achive the same result using the Graph API like this:
这些字段是可索引的,但您正在搜索字段的派生 - 每次运行查询时都会计算 lower() 函数的值,因此不会建立索引。您可能可以通过添加另一个在原始字段上运行的子句来欺骗 FB 允许它:
The fields are indexable, but you're searching on derivations of the fields - the values of the lower() function are calculated each time you run the query, so are not indexed. You can probably fool FB into allowing it by adding another clause that operates on the raw field: