solr4.1索引富文本returned non ok status:500, message:Internal Server Error求解决

大呆米 2013-03-20 10:52:44

package com.hoo.test;

import java.io.File;
import java.io.IOException;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;

import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;

public class SolrExampleTests {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
String fileName = "E://我的下载区//solr4.1.doc";
String solrId = "solr.doc";
indexFilesSolrCell(fileName,solrId);
} catch(SolrServerException e){
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

/**
* Method to index all types of files into Solr.
* @param fileName
* @param solrId s
* @throws IOException
* @throws SolrServerException
*/
public static void indexFilesSolrCell(String fileName, String solrId)
throws IOException, SolrServerException {

String urlString = "http://localhost:8080/solr/core1/";
SolrServer solr = new HttpSolrServer(urlString);

ContentStreamUpdateRequest up
= new ContentStreamUpdateRequest("/update/extract");



up.addFile(new File(fileName),"application/msword");//报错

up.setParam("literal.id", solrId);
up.setParam("fmap.content", "attr_content");

up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);

solr.request(up);

QueryResponse rsp = solr.query(new SolrQuery("*:*"));

System.out.println(rsp);
}

}


2013-3-20 10:32:20 org.apache.solr.client.solrj.impl.HttpClientUtil createClient
信息: Creating new http client, config:maxConnections=128&maxConnectionsPerHost=32&followRedirects=false
Exception in thread "main" org.apache.solr.common.SolrException: Server at http://localhost:8080/solr/core1 returned non ok status:500, message:Internal Server Error
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:373)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:181)
at com.hoo.test.SolrExampleTests.indexFilesSolrCell(SolrExampleTests.java:56)
at com.hoo.test.SolrExampleTests.main(SolrExampleTests.java:23)
...全文
441 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
等待逆袭 2013-05-22
  • 打赏
  • 举报
回复
你这是客户端的建立索引的代码,运行之后,你看看服务器端的日志是什么,就是【http://localhost:8080/solr/core1】的服务器,可能会有什么提示信息
seaside851 2013-04-11
  • 打赏
  • 举报
回复
<lib dir="../../../contrib/extraction/lib" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" /> <lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" /> <lib dir="../../../contrib/langid/lib/" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" /> <lib dir="../../../contrib/velocity/lib" regex=".*\.jar" /> <lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" /> lib中间的类包位置是否对应了。我的也出现了这个问题。根据配置文件没有找到这些jar,但是solr没有错误和日志。解决办法就是在下载的solr中,将这些位置中的jar包,添加到项目的lib中。就可以解决。
seaside851 2013-04-10
  • 打赏
  • 举报
回复
ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("update/extract");

10,606

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧