Facebook的地方:按距离排序结果

编程入门 行业动态 更新时间:2024-10-14 08:22:14
本文介绍了Facebook的地方:按距离排序结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 有没有人知道如何通过距离搜索位置点击Facebook地点?请注意,我不想在我的客户端应用程序中订购结果。我希望Facebook服务器为我提供有序的结果,以便分页。我总是想将后续查询中的地址追加到数组的末尾。

这似乎不可能使用图形API查询,例如:

https: //graph.facebook/search?q=coffee&type=place&center=37.76,-122.427&distance=1000& ....因为没有办法告诉Facebook订购结果。最近的地方可能是返回结果列表中的最后一个。

我一直在尝试使用 FQL 但有一个问题,名称& Facebook位置表中的描述字段不可索引。 FQL如:

SELECT page_id,name,display_subtext,description, distance(纬度,经度,37.76,-122.427),checkin_count FROM place WHERE((distance(纬度,经度,37.76,-122.427)< 25000 ) AND(strpos(lower(name),coffee)> = 0 OR strpos(lower(description),coffee)> = 0)) ORDER BY距离(纬度,经度,37.76,-122.427)ASC LIMIT 20 OFFSET 0

这个问题是,地址表中的名称和描述不可索引。这意味着并不是所有的结果都由FQL返回,有很多缺失的结果。

有没有人知道这样做?

解决方案

似乎可以使用这个FQL。 包含函数似乎与 q = Graph API参数相同。这是你的例子,使用包含

SELECT page_id,名称,描述,纬度,经度,checkin_count,距离(纬度,经度,37.76,-122.427) FROM place WHERE distance(纬度,经度,37.76, - 122.427)< 1000 AND CONTAINS(coffee) ORDER BY距离(纬度,经度,37.76,-122.427) LIMIT 20

Does anyone know how to order Facebook places by distance from a search location? Note that I don't want to order results in my client app. I want the Facebook server to provide me with ordered results to facilitate pagination. I always want to append places from subsequent queries to the end of my array.

This does not seem possible using the graph API query such as:

graph.facebook/search?q=coffee&type=place&center=37.76,-122.427&distance=1000&.... because there is no way to tell Facebook to order the results. The nearest place may be last in the list of returned results.

I have been trying to replicate the above query using FQL but have a problem in that the name & description fields in the Facebook place table are not indexable. FQL such as:

SELECT page_id, name, display_subtext, description, distance(latitude, longitude, "37.76", "-122.427"), checkin_count FROM place WHERE ((distance(latitude, longitude, "37.76", "-122.427") < 25000) AND (strpos(lower(name), "coffee") >= 0 OR strpos(lower(description), "coffee") >= 0)) ORDER BY distance(latitude, longitude, "37.76", "-122.427") ASC LIMIT 20 OFFSET 0

Problem with this is that the fields name and description are not indexable in the place table. This means that not all the results are returned by the FQL, there are many missing results.

Does anyone know a way to do this?

解决方案

It seems like it's possible using this FQL. The contains function seems to work the same as the q= Graph API param. Here's your example using contains

SELECT page_id, name, description, latitude, longitude, checkin_count, distance(latitude, longitude, "37.76", "-122.427") FROM place WHERE distance(latitude, longitude, "37.76", "-122.427") < 1000 AND CONTAINS("coffee") ORDER BY distance(latitude, longitude, "37.76", "-122.427") LIMIT 20

更多推荐

Facebook的地方:按距离排序结果

本文发布于:2023-10-18 15:02:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504571.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:距离   地方   Facebook

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!