sodmewuhan 2014-06-13 11:20
浏览 333
已采纳

如何向solr服务器提交大日志文件

现在公司有个项目对日志文件进行全文检索,准备用solr完成。现在遇到一个问题,由于日志的文件比较大,一般10几兆,大的已经达到几百兆了。我们将日志的内容设置为content字段,类型为string,但是当我们将documnet提交到server的时候,就报OOM的错误,请问如何解决该问题?

  • 写回答

3条回答 默认 最新

  • wuhongze 2014-06-16 10:56
    关注

    [code="java"]public static void main(String[] args) {
    try {
    //Solr cell can also index MS file (2003 version and 2007 version) types.
    String fileName = "c:/Sample.pdf";
    //this will be unique Id used by Solr to index the file contents.
    String solrId = "Sample.pdf";

      indexFilesSolrCell(fileName, solrId);
    
    } catch (Exception ex) {
      System.out.println(ex.toString());
    }
    

    }

    /**

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

      String urlString = "http://localhost:8983/solr";
      SolrServer solr = new CommonsHttpSolrServer(urlString);

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

      up.addFile(new File(fileName));

      up.setParam("literal.id", solrId);
      up.setParam("uprefix", "attr_");
      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);
      }[/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘