Using Spring Solr Data or Not for Flexible Requests as Like Backup?

杀马特。学长 韩版系。学妹 提交于 2019-12-23 03:17:13

问题


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

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?

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)?


回答1:


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 "";
  }
}

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.

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



来源:https://stackoverflow.com/questions/16824701/using-spring-solr-data-or-not-for-flexible-requests-as-like-backup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!