Search code examples
javapdfsolrsolrj

Adding pdf document to Solr in Java


I can add field like this in Java, but I want to add pdf document to Solr with SolrJ in Java, how can I add a pdf file?

CommonsHttpSolrServer server = new CommonsHttpSolrServer("http://localhost:8983/solr");

SolrInputDocument doc = new SolrInputDocument();

doc.addField("cat", "lalal");
doc.addField("id", "1");

server.add(doc);
server.commit();

Solution

  • Solr uses Apache Tika to process binary files.

    See http://wiki.apache.org/solr/ExtractingRequestHandler and http://wiki.apache.org/solr/ContentStreamUpdateRequestExample for a SolrJ example.