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/
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...
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
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)
^^^^^^^^^^^^^
精彩评论