Public search facebook user by Non-exact name - facebook

I want to do a public search on all facebook users according to the name of the user, but i want the search not to be on the exact name. for exmaple if a user will search for 'John Ada' the result 'John Adam' will be retreived too.
After that the results need to be ordered by mutual_friend_count.
I manged to do this partly with the following FQL :
SELECT uid,name, pic_square, profile_url , mutual_friend_count FROM user WHERE contains("Name Surename")
order by mutual_friend_count desc
but it returns only exact names, and if the name was missing a letter like my earlier example the user was not retreived.
I tried to mess around with the Offset and Limit but with no success either.
Thanks!

The Facebook search algorithms seem to be optimized to find full names. A partial name never seems to return as many results as a full name will. In my experience, Facebook knows how to expand names for common variants. A search for "John Adam" will return "John Adams", "Johnny Adams" and "John Addams"
The other battle you are fighting is the Facebook filtering algorithm. Facebook first finds all matches that meet your query, then filters them for visibility to your user.
You can try adding AND NOT is_blocked to your WHERE statement. This should filter out anything that isn't visible to you before the filtering algorithm.

Related

How to get nationality from Flickr Photo Search Query?

I am extracting some metadata from FLICKR PHOTO SEARCH. I have now constructed a query, which pretty much does what I want: https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=.....&text=yes&bbox=....&has_geo=1&extras=geo%2C+description&per_page=500&format=json&nojsoncallback=1&api_sig=...
I have 2 questions:
Is there any argument that provides me information on the nationality of the Flickr user?
How to modify the arguments in order to include "Tags" to the query?
thanks,
A.
Per flickr.photos.search, add &tags= to your URL query string to search by tag.
Given a photo, you can use flickr.photos.getInfo to determine the user (the owner attribute), and from there you can use flickr.people.getInfo to get the user's location. That's not the same thing as nationality, of course, but you may find that info sufficient.

Documentation for CONTAINS() in FQL?

There have recently been several questions posted on Facebook.SO using CONTAINS() in the WHERE clause. It seems to work like the Graph API search function, AND functions as an indexed field. All great things for the FQL developer.
SELECT name,
username,
type
FROM profile
WHERE CONTAINS("Facebook")
However, the only official mention of the CONTAINS function appears in the unified_thread documentation. It is mentioned in passing, as a way to search for text contained in a message. It also appeared in this fbrell code sample.
But Contains doesn't seem to be a straightforward search. For example, this query:
SELECT name
FROM user
WHERE CONTAINS("Joe Biden")
returns "Joe Biden" and also "Joseph Biden" and "Biden Joe". But it also returns "Joe Scardino", "Lindsay Noyan" and "Mehmad Moha" among others. What relationship do these people have with the VP of the USA? They aren't my friends, so I'll never know.
There also appears to be the ability to pass CONTAINS a field to search on, however changing the end of my first query to `CONTAINS("Facebook", name) returns an OAuth error:
(#615) 'name' is not a valid search field for the profile table.
In my not-so rigorous testing, I have yet to find a field/table combination that does not return this error.
So what is this mystery function? How does it work? Can it allow us to do things to date impossible in FQL like traversing arrays and filtering data stored in strings?
An answer here would be great, but a description on an FQL functions & methods reference page on the official developer documentation site would be better still.
I don't think that a have any great answers here, but I can give a workaround for the issue of returning unrelated names- which I suspect is because people have made public posts about Joe Biden, liked him, or so on. If you do the following:
SELECT name
FROM user
WHERE CONTAINS("Joe Biden")
AND strpos(lower(name),lower("Joe Biden")) >=0
You will get a resultset that only contains the right names- though it removes the advantage of also returning Joseph Biden, etc. etc.
My personal point of pain is that CONTAINS() appears to work with partial strings (e.g. "Joe Bide") on the profile table, but not on the user table. Very frustrating.

FQL, search for non-friend people and sort by mutual friends

I look for facebook users (any user, not just my friends or the friends of a specific user) with a pattern in the name, like this:
SELECT first_name,uid FROM user WHERE contains('pete')
This returns an array of people who's name contains "pete" (i.e. also "peter"). The number is quite high, so the results are of course truncated. I would like to grab, in this set (before the server-side truncation) who has most mutual friends with me (or with an arbitrary user id). However, issuing
SELECT first_name,uid FROM user WHERE contains('pete') AND mutual_friend_count > 1
gives and empty set (and no errors). I think the server truncates before applying the latter selection, as in normal SQL would happen, for performance reasons (or explicit limits I missed in the documentation).
I made a second attempt by trying to retrieve all the friends of friends of a userid, and then select on the name. However, retrieving friends of friends is not allowed (and technically difficult because some friends hide their list of friends, and this breaks the query).
I can see no other way to achieve my goal... is there any? (I mean: given a userid, search for users with highest number of mutual friends).
Your best bet, since there's no FQL solution, would be to begin a database of your own following Facebook's best practices and policies of course. That way you can structure your data. Data can be kept current by setting up Facebook's Realtime updates API (https://developers.facebook.com/docs/reference/api/realtime/) to capture when new friendships are made.
I just tried it with "order by mutual_friend_count desc" and it worked. So the query needs to be:
SELECT first_name,uid FROM user WHERE contains('pete') order by mutual_friend_count desc

User object returned from Graph API occasionally missing first_name or last_name

Sometimes when requesting users via Graph API, the objects returned are missing either the "first_name" or the "last_name" key/value pairs.
I haven't quite been able to find the pattern. Most of the time it's the "last_name" that is missing, but sometimes it's the "first_name". The "name" field typically contains what looks like a valid "[first_name] [last_name]" pair. Sometimes when the "last_name" is missing, "first_name" contains the same value as "name". Other times the value appears to be what you'd expect the "first_name" value to be based on the value of "name".
This happens for regular users (not test, which was apparently reported as bug in the past) and for a variety of locales (including en_US).
When is the first_name and/or last_name not available when requesting users from the Graph API?
Update:
Investigating this further, I noticed that occasionally what appears to be the last name is provided in the "middle_name" field instead. The registration form does not ask for a middle name, but looking at account settings I can see that one can provide an optional middle name, although the last_name is still required.
Does anyone have any feedback about whether this is a bug or if I'm running into old data that did not meet the same restrictions that are currently in place?
Try running this query: fql?q=select name,first_name,last_name from user where uid in (select uid2 from friend where uid1=me()) order by name I have friends from various parts of the world and not one of them are missing first or last.

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.