0

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();

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

9 Comments

i did this, but i get compile exception in there. up.addFile(new File(fileName));
Then you didn't do it right. Are you using the version of Solr indicated? Are you missing dependencies?
exactly . version apache solr 4.0 . Which dependencies?
So, what is the actual compilation exception you are getting?
method addFile in class org.apache.solr.client.solrj.request.ContentStreamUpdateRequest cannot be applied to given types; required: java.io.File,java.lang.String found: java.io.File reason: actual and formal argument lists differ in length
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.