Facebook fql 搜索页面与 strpos 不起作用?

发布于 2024-12-03 18:41:28 字数 913 浏览 0 评论 0原文

为什么这个查询:

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

来源:http://www.masteringapi.com/tutorials/facebook-fql-how-to-search-partial-strings-similar-to-mysql-like-operator/27/

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

Source : http://www.masteringapi.com/tutorials/facebook-fql-how-to-search-partial-strings-similar-to-mysql-like-operator/27/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

那伤。 2024-12-10 18:41:28

您不能在 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...

小帐篷 2024-12-10 18:41:28

strpos 的用法WHERE 子句中的较低运算符使它们不可索引。

在上面的示例中:

SELECT name
FROM user
WHERE uid IN (
    SELECT uid2
    FROM friend
    WHERE uid1=me()
)
AND strpos(lower(name),"jo") >=0

它之所以有效,是因为您使用了可索引字段uid
您可以使用 strpos & 降低您已有的可索引字段数据的某些子集。

在您的示例中,您没有可索引字段,因此会显示错误。

您可以使用 Graph API 获得相同的结果,如下所示:

https://graph.facebook.com/search?q=coca&type=page

Usage of strpos & lower operators in WHERE clause makes them not indexable.

In the example above:

SELECT name
FROM user
WHERE uid IN (
    SELECT uid2
    FROM friend
    WHERE uid1=me()
)
AND strpos(lower(name),"jo") >=0

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:

https://graph.facebook.com/search?q=coca&type=page
疯狂的代价 2024-12-10 18:41:28

这些字段是可索引的,但您正在搜索字段的派生 - 每次运行查询时都会计算 lower() 函数的值,因此不会建立索引。您可能可以通过添加另一个在原始字段上运行的子句来欺骗 FB 允许它:

WHERE strpos(lower(name), lower('coca')) >= 0 OR (name < 0)
                                             ^^^^^^^^^^^^^

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:

WHERE strpos(lower(name), lower('coca')) >= 0 OR (name < 0)
                                             ^^^^^^^^^^^^^
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文