Solr ExtractingRequestHandler giving empty content

2019-05-10 10:37发布

问题:

I am using ExtractingRequestHandler in Solr for getting document content and index it. It works fine for all Microsoft Documents, but for PDFs, the content being extracted is empty. I have also tried the extractOnly=true with curl, and that also returns just the empty body.

I have used TIKA independently on the same documents and that extracts content just fine. The difference is when doing independently I am using BodyContentHander that comes with Tika instead of SolrContentHandler which is used by Solr. Has anybody seen this?

I would really rather let Solr handle it than me using Tika to extract content outside of Solr.

回答1:

I just dealt with this problem for hours before figuring it out -- I was opening my PDFs in an non-binary mode, and feeding them to solr only up to the first EOF character in the file. Solr will still extract the metadata from the file (as it appears in the header of the PDF), but will return an empty body tag in its response.

This may not apply to the original poster, but it may really help someone else from wasting hours of their life.