Here is a memorandum of what to do if you get an error while using Solrj. It may increase gradually.
Generally, when initializing SolrServer, the code is as follows.
SolrServerSample.java
import java.io.IOException;
import org.apache.solr.client.solrj.*;
import org.apache.solr.client.solrj.impl.*;
public class SolrServerSample {
public static void main(String[] args) throws SolrServerException, IOException {
String url = "http://localhost:8983/solr/exampleCore";
SolrClient solr = new HttpSolrClient.Builder(url).build(); //* 1 The part that initializes SolrServer
}
}
The errors that occur in the above * 1 part are summarized.
Specifically, the error is as follows.
The required jar file may not be included in the build path. Include the following jars in the dist-> solrj-lib folder in the solr6.x.x folder that you think you have downloaded in advance in your build path. (x is the version number)
Specifically, the error is as follows.
Download the latest slf4j from the slf4j download page and add the following jar files inside to your build path. (x is the version number)
If the above jar already exists, remove it and replace it with the latest one.
SolrDocumentSample.java
import java.io.IOException;
import org.apache.solr.client.solrj.*;
import org.apache.solr.client.solrj.impl.*;
public class SolrDocumentSample {
public static void main(String[] args) throws SolrServerException, IOException {
String url = "http://localhost:8983/solr/exampleCore";
SolrClient solr = new HttpSolrClient.Builder(url).build();
SolrInputDocument document = new SolrInputDocument(); //* 2 Part that generates SolrInputDocument
}
}
The errors that occur in the above * 2 part are summarized.
Specifically, the error is as follows.
The required jar file may not be included in the build path. Include the following jars in the dist-> solrj-lib folder in the solr6.x.x folder that you think you have downloaded in advance in your build path. (x is the version number)
Recommended Posts