是否将Spring Solr数据用于像备份一样的灵活请求? [英] Using Spring Solr Data or Not for Flexible Requests as Like Backup?

查看:91
本文介绍了是否将Spring Solr数据用于像备份一样的灵活请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Spring上实现一个与我当前的Solr或SolrCloud交互的应用程序.我考虑是否使用Spring Data Solr.但是我认为,如果我只运行这样的查询,则还没有实现CloudSolrServer:

I want to implement an application at Spring that interacts with my current Solr or SolrCloud. I consider of using Spring Data Solr or not. However I think that there is no CloudSolrServer implemented at it yet on the other hand if I just run a query like that:

http://localhost:8983/solr/replication?command=backup

并检查备份是否完成(我将执行get请求,解析JSON,并查看上次备份时间是否已更改)如何将其与Spring Data Solr集成?

and check whether backup is completed or not(I will do a get request, parse JSON and will see that last backup time is changed or not) How I can integrate it with Spring Data Solr?

我的意思是在我的情况下使用Spring + Solrj而不是Spring Data Solr更有意义(也就是说,我想做一些更灵活的事情,而仅仅是使用Spring在Solr上进行CRUD操作)?

I mean is it more meaningful using Spring + Solrj instead of Spring Data Solr at my situation (that is I want to do more flexible things that just CRUD operations on Solr with Spring)?

推荐答案

是的,还不支持CloudSolrServer.您可以做的就是为您提供自己的SolrServerFactory.

True, there is no support for CloudSolrServer yet. What you can do is provide you own SolrServerFactory.

public class CloudSolrServerFactory implements SolrServerFactory {

  private final CloudSolrServer solrServer;

  public CloudSolrServerFactory(String zkHost) throws MalformedURLException{
    this.solrServer = new CloudSolrServer(zkHost);
  }

  @Override
  public SolrServer getSolrServer() {
    return this.solrServer;
  }

  @Override
  public String getCore() {
    return "";
  }
}

接下来,您可以按照 Spring Data Commons文档的第1.3节.看看(不是您的问题的实现,而是自定义存储库的一般用法)了解它可能如何工作.

Next you can add custom behavior to all your repositories as described in Section 1.3 of Spring Data Commons documentation. Have a look at this (not an implementation of your issue, rather general usage of custom repositories) to get the idea of how it might work.

请随时打开功能请求,因为这肯定是Spring Data Solr所缺少的.

Please feel free to open a feature request as this is definitely something missing Spring Data Solr.

这篇关于是否将Spring Solr数据用于像备份一样的灵活请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆