Search people by name in FQL

I am trying to develop a search for people by name using the Facebook API.

I am trying to execute this FQL query:

SELECT uid, username, name, pic_square FROM user WHERE strpos(name, 'Alfredo Artiles') >= 0

But I get . " Your statement is not indexed. The WHERE clause must contain an indexed column error ..

I also tried adding the condition "and uid> 0", but that didn't work either.

Any idea?

+3
source share
4 answers

edit later

, strpos, , fql. , . primar where strpos ( , ). :

SELECT actor_id, message FROM stream WHERE source_id = me() AND strpos(message, 'stuff') > 0 limit 50

, .

+4
SELECT uid, username, name, pic_square FROM user WHERE contains('Alfredo Artiles')

, , " ", .

EDIT: :

+6

U uid , facebook. .

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

, !!!

Try searching the profile table instead of the user table. In the profile table, the name field is indexed, so your operator will need to change a little:

SELECT id, username, name, pic_square FROM profile WHERE contains('alfredo artiles') and type='user'

Contains not case sensitivity, but strpos. You can still use the lower and strpos, but you will also have a special character problem. Contains a solution.

You can find all the fields of the profile table in facebook doc :

Hope this helps!

0
source

Source: https://habr.com/ru/post/1779029/


All Articles