开发者

Search for people by name in FQL

开发者 https://www.devze.com 2023-01-29 13:21 出处:网络
I\'m trying to develop a search for people by name feature using the Facebook API. I\'m trying this FQL query:

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开发者_StackOverflow社区 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!

0

精彩评论

暂无评论...
验证码 换一张
取 消