FQL like operator - facebook

Can someone tell me why this works:
SELECT name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND strpos(lower(name),"jo") >=0
however this does not:
"SELECT url, id, type, site FROM object_url WHERE strpos(lower(url), 'sephora') >= 0"
When I put it in http://developers.facebook.com/docs/reference/rest/fql.query/
I get this response:
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
however "url" in indeed indexable.
any thoughts? I've already scoured stackoverflow but no answers found.

Site isn't indexable, it's only selectable. It doesn't have an * next to it here https://developers.facebook.com/docs/reference/fql/object_url/
you need to use url or id as the indexable column, so basically one of those needs to be in your where clause.

FQL != SQL You can't a a WHERE on any column you want. Not surprising considering the performance required with so many concurrent writers, I mean, one person in every ten in the world has signed up.
The problem in the second example is that a field used as a parameter in one of the string functions loses its indexability. It has to be the column itself.

Related

Facebook FQL Searching Pages Using Partial String

I'm trying to search for a company's different branches using a partial string. Here's the query I'm using:
SELECT name, location, fan_count, talking_about_count, were_here_count
FROM page WHERE strpos(name, "Applebee's") >= 0 OR (name < 0)
I get the error:
Your statement is not indexable. The WHERE clause must contain an
indexable column.
Name is listed as indexable, so I'm not sure why this error is occurring.
You can use function CONTAINS():
SELECT name, location, fan_count, talking_about_count, were_here_count FROM page WHERE CONTAINS("Applebee's") and strpos(name, "Applebee's") >=0
This query will output all results which will contain Applebee's in name.

Facebook FQL Query, searching on non-indexable item

I would like to generate a list of facebook user id's of people who are not in the United States. Rather than iterating through a list of user id's and checking each locale, I would like to do an FQL query. I attempted to execute this statement:
SELECT uid, name FROM user WHERE locale != "en_US"
However, when I make the query, I recieve the response:
(code 604): Your statement is not indexable.
This is because locale is not an indexable field. Do any of you know what I can do to get around this? Or perhaps another way of doing this entirely?
Thanks in advance!
It says "Your statement is not indexable." That means, you can't just use any query (like, extreme case, SELECT uid, name FROM user to get all facebook users) that does not conform. Only queries that include WHERE on fields that are indexable can be used. It's a policy, you can not circumvent it.

How could I use FQL to query all the events without using indexable column which is marked *

I have a problem to solve.
I want to query all the events and I want to find the specific string.
The FQL code is like the following:
SELECT eid, name, location, start_time, end_time FROM event WHERE strpos(lower(location),'test') >=0
When I used this FQL code,it always occurred error.
The error message is "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"
Please,give me your point of views~thank you :)
Well, the error message is clear:
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
So simply your approach won't work.
EDIT:
To further explain why this is not possible:
Facebook deals with "over than 900 million objects that people interact with (pages, groups, events and community pages)". reference.
So basically giving you (all App devs) the ability to search ALL pages, events, groups...etc will definitely bring the system down. This is why these "indexible" fields are selected carefully.
For instance, if you want to search events by "location" then these events should be "somehow" related to your application. Like created by your App for example, and you should have their ids stored somewhere so that something like this would work:
SELECT eid, name, location, start_time, end_time FROM event WHERE
strpos(lower(location),'test') >=0 AND eid IN (ids_from_your_db)

How to retrieve page ids based on type using FQL?

I want to retrieve page ids of all those pages whose type is Musician/Band. I tried to retrive it from page table as
SELECT page_id from page where type='MUSICIAN/BAND'
but it is not allowing that.Its giving error:
Your statement is not indexable. The WHERE clause must contain an indexable column.
How to go about this?
You simply cannot do that query. You need to include at least one of the indexable columns in your query (page_id or name).

Search for people by name in FQL

I'm trying to develop a search for people by name feature using the Facebook API.
I'm trying this FQL query:
SELECT uid, username, name, pic_square FROM user WHERE strpos(name, 'Alfredo Artiles') >= 0
But I get an "Your statement is not indexable. The WHERE clause must contain an indexable column." error.
I also tried to add a "and uid > 0" condition, but that didn't work too.
Any idea?
SELECT uid, username, name, pic_square FROM user WHERE contains('Alfredo Artiles')
I have no idea why it works, as it violates the "at least and indexable field in WHERE", but it does.
EDIT: this is where I read it: link
later edit
Ok, sorry for the mistake regarding strpos, I didn't remeber it existence last time i checked the fql docs. The thing about it is that it can be used just in certain cases. You need to have a primar indexable column in your where clause and a second condition with strpos (at least this is how I succeded using it). For example:
SELECT actor_id, message FROM stream WHERE source_id = me() AND strpos(message, 'stuff') > 0 limit 50
I hope this clarifies a little bit the confusion with this function.
U need to specify the uid in where clause fetch details in facebook user table. we don't get the the all user details.here get the details of currently logged in user
"SELECT name FROM user WHERE uid IN(SELECT uid2 FROM
friend WHERE uid1 = me()) AND strpos(name,'Alfredo Artiles') >=0"
YES, YOU CAN!!!
Try to search in profile table, instead of user table. In profile table, the name field is indexable, so your statement would have to change only a bit:
SELECT id, username, name, pic_square FROM profile WHERE contains('alfredo artiles') and type='user'
Contains is not case-sensitive while strpos is. You could still use lower and strpos, but you would also have the problem of special characters. Contains is the solution.
You can find all fields of profile table in facebook doc:
Hope it helps!