Let's say I want to search for McDonalds in a certain location using Facebook's graph API, like so. Now, since I know that Facebook won't always give me back all the results I want on the first page, or even the number of results I asked for, I follow the pagination link. This is the one I was given. Now, this second page loses the query string, and returns a bunch of results near the search location, but having nothing at all to do with McDonalds (e.g. Tufenkian Artisan Carpets Chicago). How can I tell when I have no more applicable results, if the pagination drops my original query entirely?
It looks like removing the limit parameter causes pagination to correctly have the query on future pages: see the same search without the limit parameter.
Related
I have a search field, which lets the user search books (filters records, which are retrieved with ember-data).
I have found that any access the store from the results computed property within my component (see jsbin) makes the typing into the search field very slow (noticeable on my PC, and terrible on smartphone).
Here is a screenshot of the Timeline pane when typing a search query. The displayed part show that every keypress causes A LOT of layout (the search field seems to rerendered on every keypress). I also provide the exported timeline which you can load into your dev tools as explained here
I have tried to recreate the issue in a jsfiddle, but it seems to work just fine. The difference might be that in the jsbin I am using fixtures, while in my app I retrieve data from a real API.
I don't understand what is causing this behavior. It may be hard to come to any conclusion from the data I can provide, but does anyone have any ideas? Has anyone experienced similar performance issues?
Update 2014-03-01
I should note that the performance hit only happens if the results computed property contains a call to the store. If I replace it with any other thing (like just returning [], or some random async method -- like $.get) it not display this performance hit.
Additionally, I should make it clear (in case you didn't read the code), that the results computed property is not called on every keypress, but only when the search is submitted.
This is not a Ember/Ember-data bug, but apparently a Google Chrome bug.
I have created a new question regarding the issue here
Could someone do me a flavour and let me know if you also get back an empty json array when you click on the sample user search url on the Facebook Graph Api docs page.
Here is the page http://developers.facebook.com/docs/reference/api/
It is in the search section. the people link.
Here is the link I am clicking and all other search links return data except the user search.
This is what I get back
My question is do other people have this problem as well or is it just me.
My suspicion is that it has to do with the way Facebook filters by privacy after they've selected your results. Meaning graph asks for (X) results, Facebook finds (X) results that match your search, then removes those who have it in their privacy options not me be searched, and then after filtering returns what's left. This is explained on Facebook's dev blog: https://developers.facebook.com/blog/post/478/
See the following answer for clearer details: https://stackoverflow.com/a/11848002/624590
That said, it could be something else - I've noticed it's been getting especially bad in recent weeks; fewer and fewer results seem to be returned.
We've been getting empty results for type=post for periods of 1-2 hours for the past few days. I'm sure it's related to something on their end, check out my bug post here http://developers.facebook.com/bugs/456910301017301?browse=search_509b0461dc68c0151458645
Say I have a website that has 100 products. Then this is filtered down to 5 sections containing 20 products each. If you were in one of the sections that contained 20 products (e.g. toys), what would be the optimal method to display only 5 toys per page. At the bottom of the list would be next/previous buttons to show the next/previous set of 5 toys.
A better analogy would be google search. There are millions of results but only ~10 are shown at a given time.
So right now I'm using google app engine (python) and django templates. One way I thought of to remedy this problem would be making all the query results go into a div which could then be modified through javascript to give a similar effect. However, if someone were to click their browser's back button, they wouldn't go where they originally came from.
Thanks in advance. Any help would be useful...I don't know what this technique is called so google hasn't been really useful :(
Edit: based on responses, I found my question was solved here: How to use cursor() for pagination?
Look into query cursors. Thay are made to be serialized and sent to client, to be used in creating "next" and "previous" paging requests.
NOTE: don't use offset on queries. This can be VERY expensive, as it actually fetches (and charges) all entities up to offset+limit position, but returns to application only limit results.
I'm not sure that putting all the results as hidden content in the HTML and manipulating it using JS is a very good idea if you might have a large result set (think about what happened if Google used this approach). There's also the back functionality issue that you've mentioned.
So, as for querying a wanted "results page" each time, I think the Google's GQL Reference might help you, take a look specifically at the LIMIT clause, it can help you create the paging mechanism you're looking for by supplying it with the number of items-per-page you want as "count" and the numbers of items-previously-viewed as "offset" (0 at first call).
As for displaying, I think that the Google Images / Facebook News Feed approach might also be interesting to think about (loading on scroll instead of paging), but that's a matter of your personal choice :)
Hope this helps, good luck!
EDIT: After reading Peter's answer, I found it much more efficient to use cursors for pagination, a good reference is given in his answer.
I am writing an application that needs to retrieve all posts on any given facebook page. For the McDonald's page, I would use this url:
https://graph.facebook.com/McDonalds/posts?access_token=xxx&limit=5000
The problem is that first, I do not receive any posts older than 2011-11-01 and the number of posts shown is much less than 5000. This means that the limit parameter isn't working properly. I looked this up and found that it was a known bug.
Then I tried to follow the next and previous paging information provided in the end and even using that I can't get past 2011-01-24. After following the next link 2 times, an empty page comes up. The McDonalds page is much older and contains more posts. So the question is, how on earth am I supposed to retrieve older posts. Is there any workaround at all?
There is a limit on the limit. Try using since & until to extend the date params
https://graph.facebook.com/McDonalds/posts?access_token=xxx&limit=5000&since=2+years+ago&until=now
&limit=5000&since=2+years+ago&until=now
&limit=5000&since=3+years+ago&until=now
I'm looking to make something similar to the location autocomplete in Facebook's "Create Event" page. It gives location name, address, and number of check-ins. Do you know how is it done? Because the Places table does not have any field for address and nubmer of checkins.
https://developers.facebook.com/docs/reference/fql/place/
I was going to use Factual, but after some trial and error, found out that facebook is more comprehensive.
Try this query. It ensures that the checkins field is also returned as part of the search request.
https://graph.facebook.com/search?q=coffee&type=place¢er=37.76,-122.427&distance=1000&fields=location,name,id,checkins
There is a graph place search API.
https://graph.facebook.com/search?q=coffee&type=place