Reputation: 189
I've been trying to index pdf documents using Cloudera Search aka Apache Solr. First I was able to index twitter tweets. Later I tried to index PDF files. I've created the corresponding collection using solrctl
with default schema. The morphline file that I used is (I've masked the IP address of zkHost here)...
solrLocator : {
# Name of solr collection
#collection : collection1
collection : pdfs
# ZooKeeper ensemble
#zkHost : "127.0.0.1:2181/solr"
zkHost : "xxx.xxx.xxx.xxx:2181,xxx.xxx.xxx.xxx:2181/solr"
# The maximum number of documents to send to Solr per network batch (throughput knob)
# batchSize : 100
}
morphlines : [
{
id : morphlinepdfs
importCommands : ["org.kitesdk.**", "org.apache.solr.**"]
commands : [
{ detectMimeType { includeDefaultMimeTypes : true } }
{
solrCell {
solrLocator : ${solrLocator}
captureAttr : true
lowernames : true
capture : [id, title, author, content, content_type, subject, description, keywords, category, resourcename, url, last_modified, links]
parsers : [ { parser : org.apache.tika.parser.pdf.PDFParser } ]
}
}
{ generateUUID { field : id } }
{ sanitizeUnknownSolrFields { solrLocator : ${solrLocator} } }
{ loadSolr: { solrLocator : ${solrLocator} } }
]
}
]
The PDF metadata fields are present in schema.xml file such as...
<field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="subject" type="text_general" indexed="true" stored="true"/>
<field name="description" type="text_general" indexed="true" stored="true"/>
<field name="comments" type="text_general" indexed="true" stored="true"/>
<field name="author" type="text_general" indexed="true" stored="true"/>
<field name="keywords" type="text_general" indexed="true" stored="true"/>
<field name="category" type="text_general" indexed="true" stored="true"/>
<field name="resourcename" type="text_general" indexed="true" stored="true"/>
<field name="url" type="text_general" indexed="true" stored="true"/>
<field name="content_type" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="last_modified" type="date" indexed="true" stored="true"/>
<field name="links" type="string" indexed="true" stored="true" multiValued="true"/>
But in the solr /select query output, I'm getting only content and content-type fields. How can I get all the metadata in solr frontend query? Do I need to modify the schema.xml or the corresponding morphline file? Also can I index the fields inside the PDF content?
The command I used to index pdf file is:
hadoop --config /etc/hadoop/conf.cloudera.yarn jar /usr/lib/solr/contrib/mr/search-mr-1.0.0-cdh5.8.2-job.jar org.apache.solr.hadoop.MapReduceIndexerTool -D 'mapred.child.java.opts=-Xmx500m' --log4j /usr/share/doc/search-1.0.0+cdh5.8.2+0/examples/solr-nrt/log4j.properties --morphline-file /usr/share/doc/search-1.0.0+cdh5.8.2+0/examples/solr-nrt/test-morphlines/solrPDF.conf --output-dir hdfs://xxxxxx:8020/user/root/outdir --verbose --go-live --zk-host xxxxx:2181/solr --collection pdfs hdfs://xxxxxx:8020/user/root/indir
Thanks in advance.
Upvotes: 0
Views: 485
Reputation: 189
I've found the problem. In fact, the PDF file that I was using don't have any metadata. I've tried with other PDF files and got the results. Hope it helps others.
Upvotes: 0