当弹性搜索不可用时,休眠搜索后备
即使没有弹性搜索群集,还有冬眠搜索中的后备机制,以便能够执行搜索?我知道这些索引存储在弹性搜索中,但是在这种情况下,冬眠搜索可以忽略索引并执行默认搜索吗?有没有办法设置此问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
即使没有弹性搜索群集,还有冬眠搜索中的后备机制,以便能够执行搜索?我知道这些索引存储在弹性搜索中,但是在这种情况下,冬眠搜索可以忽略索引并执行默认搜索吗?有没有办法设置此问题?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
否。如果Hibernate Search使用Elasticsearch后端,则使用后端使用 。如果Elasticsearch降低,休眠搜索将下降。
如果您想要“默认搜索”(无论这意味着什么),则需要在自己的代码中实现它,例如:
关于如何确定是否可用,您可以使用基本的REST客户端向Elasticsearch发送请求(如果没有Elasticsearch,一定会失败)。
相似(但不完全相同)的问题: https://discourse.hibernate.org/t/how-to-to-to-sknow-if-if-index-alreade-already-exist-exist-in--elaster-server/6207
编辑:也许更好的方法是一种更好的方法尝试正常的搜索,捕获异常,然后退后,例如:
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.:
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.: