在REST API中处理“搜索”的最佳方法是什么?狮身人面像怎么样?

时间:2022-06-29 20:09:17

When there are a lot of results, and they are always changing - what's the best way to handle "search" in a REST API?

当有很多结果,并且它们总是在变化时 - 在REST API中处理“搜索”的最佳方法是什么?

Background: I have a community-service website that lists free local items for churches, community groups, or struggling families - so we have a lot of listings usually from donors, or scanned on other websites. Ideally a REST API for this website would call up listings based on certain criteria that we outline in the methods - But there can be a lot of results, and they're always changing!

背景:我有一个社区服务网站,列出了教堂,社区团体或苦苦挣扎的家庭的免费本地项目 - 所以我们通常有很多来自捐赠者的列表,或者在其他网站上扫描。理想情况下,这个网站的REST API会根据我们在方法中列出的某些标准来调用列表 - 但是可能会有很多结果,并且它们总是在变化!

Something like Sphinx Search? We allow distance searches (all listings are geo-tagged) - I've seen that Sphinx Search has a native (fast!) distance-search function, and also caches searches - is it typical to include some type of search engine in a REST API? I'm guessing it would be an interface between the API and another application on the server like Sphinx...

像狮身人面像搜索?我们允许距离搜索(所有列表都是地理标记的) - 我已经看到Sphinx Search具有本机(快速!)距离搜索功能,并且还可以缓存搜索 - 在REST中包含某种类型的搜索引擎是典型的API?我猜这将是API与服务器上的另一个应用程序之间的接口,如Sphinx ......

1 个解决方案

#1


0  

I'm not exactly sure I understand your question. Your main concern seems to be that the data is changing frequently, but that is the case with many search engines. Consider *, they allow you to retrieve a search result by using the following:

我不确定我理解你的问题。您的主要关注点似乎是数据经常变化,但许多搜索引擎就是这种情况。考虑*,它们允许您使用以下方法检索搜索结果:

http://*.com/search?q=foo

If you call it a few minutes later you will get a different result. What technology you use behind the scenes to do the search really does not affect the exposed resources. How long you cache those results depends on how long you believe those results will be valid for and how likely someone else is to make the exact same request.

如果几分钟后再打电话,你会得到不同的结果。您在幕后使用什么技术进行搜索确实不会影响公开的资源。缓存这些结果的时间取决于您认为这些结果有效的时间以及其他人提出完全相同请求的可能性。

I think I must be missing something here.

我想我必须在这里遗漏一些东西。

#1


0  

I'm not exactly sure I understand your question. Your main concern seems to be that the data is changing frequently, but that is the case with many search engines. Consider *, they allow you to retrieve a search result by using the following:

我不确定我理解你的问题。您的主要关注点似乎是数据经常变化,但许多搜索引擎就是这种情况。考虑*,它们允许您使用以下方法检索搜索结果:

http://*.com/search?q=foo

If you call it a few minutes later you will get a different result. What technology you use behind the scenes to do the search really does not affect the exposed resources. How long you cache those results depends on how long you believe those results will be valid for and how likely someone else is to make the exact same request.

如果几分钟后再打电话,你会得到不同的结果。您在幕后使用什么技术进行搜索确实不会影响公开的资源。缓存这些结果的时间取决于您认为这些结果有效的时间以及其他人提出完全相同请求的可能性。

I think I must be missing something here.

我想我必须在这里遗漏一些东西。