当弹性搜索不可用时,休眠搜索后备

发布于 2025-02-07 07:16:50 字数 95 浏览 0 评论 0 原文

即使没有弹性搜索群集,还有冬眠搜索中的后备机制,以便能够执行搜索?我知道这些索引存储在弹性搜索中,但是在这种情况下,冬眠搜索可以忽略索引并执行默认搜索吗?有没有办法设置此问题?

Is there a fallback mechanism in Hibernate Search in order to be able to perform a search even when Elastic search cluster is not available? I know that the indexes are stored in Elastic search but can Hibernate search in this case just ignore the indexes and perform a default search? Is there a way to set this up?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尸血腥色 2025-02-14 07:16:50

否。如果Hibernate Search使用Elasticsearch后端,则使用后端使用 。如果Elasticsearch降低,休眠搜索将下降。

如果您想要“默认搜索”(无论这意味着什么),则需要在自己的代码中实现它,例如:

if ( elasticsearch available ) {
   // execute a query using Hibernate Search
}
else {
   // implement some "default" search, whatever that means
}

关于如何确定是否可用,您可以使用基本的REST客户端向Elasticsearch发送请求(如果没有Elasticsearch,一定会失败)。

相似(但不完全相同)的问题: https://discourse.hibernate.org/t/how-to-to-to-sknow-if-if-index-alreade-already-exist-exist-in--elaster-server/6207

编辑:也许更好的方法是一种更好的方法尝试正常的搜索,捕获异常,然后退后,例如:

try {

}
catch (SearchException e) {
   if ( e.getMessage().contains("connect") ) {
       // implement some "default" search, whatever that means
   }
   else {
      throw e;
   }
}

No. If Hibernate Search uses an Elasticsearch backend, it uses only that backend. If Elasticsearch is down, Hibernate Search is down.

If you want a "default search" (whatever that means), you will need to implement it in your own code, e.g.:

if ( elasticsearch available ) {
   // execute a query using Hibernate Search
}
else {
   // implement some "default" search, whatever that means
}

As to how you determine whether Elasticsearch is available, you could send a request to Elasticsearch using the underlying Rest client, or alternatively just run schema validation (which will necessarily fail if Elasticsearch is not available).

Similar (but not identical) question: https://discourse.hibernate.org/t/how-to-know-if-index-already-exist-in-elastic-server/6207

EDIT: Perhaps a better approach would be to try a normal search, catch exceptions and then fall back, e.g.:

try {

}
catch (SearchException e) {
   if ( e.getMessage().contains("connect") ) {
       // implement some "default" search, whatever that means
   }
   else {
      throw e;
   }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文