Masalah pelik apabila membuat indeks menggunakan solrj?
伊谢尔伦
伊谢尔伦 2017-06-15 09:22:21
0
1
1934

@RequestMapping(nilai = "/solr", kaedah = RequestMethod.GET)

public void getSolr() throws SolrServerException, IOException {

    String urlString = "http://192.168.10.129:8983/solr/mycore";
    SolrClient client = new HttpSolrClient.Builder(urlString).build();
    SolrInputDocument doc = new SolrInputDocument();
    doc.addField("id", "c");
    client.add(doc);
    client.commit();
}

Hanya buat indeks dan kemudian laporkan ralat

Disebabkan oleh: org.apache.solr.client.solrj.SolrServerException: IOException berlaku apabila bercakap dengan pelayan di: http://192.168.10.129:8983/so...

at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:624)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:279)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:268)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:160)
at org.apache.solr.client.solrj.SolrClient.commit(SolrClient.java:484)
at org.apache.solr.client.solrj.SolrClient.commit(SolrClient.java:463)
at com.ansel.testall.solrController.getSolr(solrController.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
... 52 common frames omitted

Disebabkan oleh: org.apache.http.NoHttpResponseException: 192.168.10.129:8983 gagal bertindak balas

at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:141)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281)
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:257)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:207)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:684)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:515)
... 71 common frames omitted

doc telah ditambahkan, tetapi komit gagal.

Jika anda membahagikan tambah dokumen dan komit kepada 2 permintaan, tidak akan ada masalah, seperti berikut:

@RequestMapping(value = "/solr", method = RequestMethod.GET)
    public void getSolr() throws SolrServerException, IOException {

        String urlString = "http://192.168.10.129:8983/solr/mycore";
        SolrClient client = new HttpSolrClient.Builder(urlString).build();
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", "c");
        client.add(doc);
    }
    @RequestMapping(value = "/solr2", method = RequestMethod.GET)
    public void getSolr2() throws SolrServerException, IOException {

        String urlString = "http://192.168.10.129:8983/solr/mycore";
        SolrClient client = new HttpSolrClient.Builder(urlString).build();
        client.commit();
    }

Tiada masalah dalam melaksanakan operasi pertanyaan.

solr: 6.60

jdk: 1.8

Situasi serupa iteye sebelum ini:

http://www.iteye.com/problems...

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

membalas semua(1)
为情所困

Penyelesaian sementara, gunakan kaedah berikut untuk menghantar:

UpdateRequest req = new UpdateRequest();
        req.setAction(UpdateRequest.ACTION.COMMIT, false, false);
        req.add(doc);
        UpdateResponse rsp = req.process(client);

Ditemui di https://wiki.apache.org/solr/...,
Ini ialah terjemahan separa http://www.cnblogs.com/llz502...

Kenapa ni okay? Masih sangat pelik

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan