einpublic void testConnection() {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
String urlString = "http://solr_IP/solr/core_name";
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(
new AuthScope(AuthScope.ANY),
new UsernamePasswordCredentials("user", "password")
);
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(10000)
.setConnectTimeout(10000)
.build();
CloseableHttpClient httpClient = HttpClients.custom()
.setDefaultCredentialsProvider(credentialsProvider)
.setDefaultRequestConfig(requestConfig)
.build();
HttpSolrClient solr = new HttpSolrClient.Builder(urlString)
.withHttpClient(httpClient)
.withResponseParser(new XMLResponseParser())
.build();
solr.setParser(new XMLResponseParser());
try {
SolrQuery query = new SolrQuery();
query.setQuery("strain_id:999");
QueryResponse response = solr.query(query);
SolrDocumentList results = response.getResults();
for (SolrDocument doc : results) {
System.out.println("Found document: " + doc + "\n");
}
System.out.println("Creating a new strain\n");
SolrInputDocument doc = new SolrInputDocument();
doc.addField("strain_id", 9999);
doc.addField("do_id", "DOID: 9744 modified");
System.out.println("Adding strain.\n");
solr.add(doc);
System.out.println("Commit changes.\n");
solr.commit();
System.out.println("New strain added.\n");
} catch (SolrServerException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
System.out.println();
}
< /code>
Aber jedes Mal, wenn ich den folgenden Fehler erhalte: < /p>
Found document: SolrDocument{id=999, strain_id=999, do_id=DOID: 9744, _version_=1829001984233963520}
Creating a new strain
Adding strain.
org.apache.solr.client.solrj.SolrServerException: IOException occurred when talking to server at: http://solr_IP/solr/core_name
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:695)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:266)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:248)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:225)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:177)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:138)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:156)
at org.example.TestLoader.testConnection(TestLoader.java:72)
at org.example.TestLoader.main(TestLoader.java:95)
Caused by: org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:187)
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:571)
... 8 more
Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity.
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:225)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
... 11 more
java.lang.RuntimeException: org.apache.solr.client.solrj.SolrServerException: IOException occurred when talking to server at: http://87.106.58.218:8983/solr/strain_disease
at org.example.TestLoader.testConnection(TestLoader.java:79)
at org.example.TestLoader.main(TestLoader.java:95)
Caused by: org.apache.solr.client.solrj.SolrServerException: IOException occurred when talking to server at: http://87.106.58.218:8983/solr/strain_disease
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:695)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:266)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:248)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:225)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:177)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:138)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:156)
at org.example.TestLoader.testConnection(TestLoader.java:72)
... 1 more
Caused by: org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:187)
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:571)
... 8 more
Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity.
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:225)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
... 11 more
Process finished with exit code 0
< /code>
Daher kann der Lesevorgang ohne Probleme ausgeführt werden, aber das Schreiben erhöht immer diesen Fehler.>
Solrj -Schreibvorgänge fehlschlagen ⇐ Java
-
- Similar Topics
- Replies
- Views
- Last post