我使用java客戶端程序將索引數據添加到索引服務器中。我的來源是這樣的: -java.lang.NoClassDefFoundError:org/noggit/CharArr同時添加要索引的文檔在solr
SolrServer solrServer = new HttpSolrServer("http://10.219.224.91:4040/solr/test");
System.out.println("<ul>");
String[] passengerType={"Infant","Handicapped","Unaccompanied minor", "General Category"};
for(int i = 0; i < 100; i++) {
SolrInputDocument solrInputDocument = new SolrInputDocument();
solrInputDocument.addField("id", new String("widget " + i));
// add three random categories
for(int j = 0; j < 3; j++) {
solrInputDocument.addField("category", passengerType[new Random().nextInt(passengerType.length)]);
}
solrInputDocument.addField("size", new Random().nextInt(10));
// this is cheating below - but saves us from the query string...
solrInputDocument.addField("text", "a");
solrServer.add(solrInputDocument);
System.out.println("<li> Adding: " + solrInputDocument + "</li>\n");
}
System.out.println("</ul>");
solrServer.commit();
在運行我得到了應用: -
Exception in thread "main" java.lang.NoClassDefFoundError: org/noggit/CharArr at org.apache.solr.common.util.JavaBinCodec.(JavaBinCodec.java:474) at org.apache.solr.client.solrj.impl.BinaryResponseParser.processResponse(BinaryResponseParser.java:41) at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:407) at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:180) at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:117) at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:116) at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:102) at IndexDriver.main(IndexDriver.java:39) Caused by: java.lang.ClassNotFoundException: org.noggit.CharArr at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source)
錯誤是在這個未來LINE-
solrServer.add(solrInputDocument);
任何幫助將得到高度讚賞。
工作在Solr的框架提供的jar對我來說感謝 – mcacorner
更好地使用一個顯示所有版本的jar文件的網站,比如https://maven-repository.com/artifact/org.noggit/noggit –