对于使用 Rails 和 Java 后端的项目,在哪里构建 ElasticSearch 查询,前端还是后端?

For a project using Rails with Java backend, where to construct ElasticSearch query, front end or back end?

我正在 Rails 上使用 Ruby 编写一个项目,以 Java 作为后端。我注意到 ElasticSearch 有一个开源 Ruby client where it could construct JSON query, and it also has Java API

在这种情况下,我应该使用Ruby 客户端(在前端创建查询)还是Java API 客户端(在后端创建查询)?每种方法的优缺点是什么?

Java API has direct access to the database not Rails. Currently, all the query has to go through the Java API.

你还有疑问吗?

如果您的 rails 应用程序用作客户端,那就随它去吧。并让您的 Java/backend 显式处理后端。只需从您的 rails 应用程序传递查询参数,然后从您的 Java 应用程序构建、执行和 return 查询结果。