用码头启动 Solr

Start Solr with jetty

本文关键字:Solr 启动 码头      更新时间:2023-10-16

我有一个示例代码java,可以使用Solr搜索我的索引数据。

public class SimpleSolr 
{
    public static void main(String[] args) throws MalformedURLException, SolrServerException 
    {
      HttpSolrServer solr = new HttpSolrServer("http://localhost:8983/solr");
      // http://localhost:8983/solr/spellCheckCompRH?q=epod&spellcheck=on&spellcheck.build=true
      ModifiableSolrParams params = new ModifiableSolrParams();
      params.set("qt", "/select");
      params.set("q", "international");
      params.set("wt", "xml");
      //params.set("spellcheck.build", "true");
      QueryResponse response = solr.query(params);
      System.out.println("response = " + response);
  }
}

但是在执行此客户端应用程序之前,我需要使用此命令启动我的 solr

java -jar start.jar

我需要自动启动我的 solr 服务器。

我该怎么做?

我需要知道从我的 C++ 应用程序与我的 solr 服务器通信的 bset 方式是什么?

谢谢。

要在启动时运行 solr 服务器,您可能需要查看以下线程: https://superuser.com/questions/685471/how-can-i-run-a-command-after-boot

要从C++应用程序与Solr服务器进行通信,最简单的方法是通过在查询中添加&wt=json来使用服务器的json api。

http://localhost:8983/solr/your_core/select?q={!dismax}&wt=json&indent=true

然后,您可以使用优秀的 JsonCPP (https://github.com/open-source-parsers/jsoncpp) 解析收到的 json。