13.05.2014 Views

apache-solr-ref-guide-4.6.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Add Documents<br />

Solr is built to find documents that match queries. Solr's schema provides an idea of how content is structured (more on the schema later), but<br />

without documents there is nothing to find. Solr needs input before it can do anything.<br />

You may want to add a few sample documents before trying to index your own content. The Solr installation comes with example documents<br />

located in the example/exampledocs directory of your installation.<br />

In the exampledocs directory is the SimplePostTool, a Java-based command line tool, post.jar, which can be used to index the documents.<br />

Do not worry too much about the details for now. The Indexing and Basic Data Operations section has all the details on indexing.<br />

To see some information about the usage of post.jar, use the -help option.<br />

$ java -jar post.jar -help<br />

The SimplePostTool is a simple command line tool for POSTing raw XML to a Solr port. XML data can be read from files specified as command<br />

line arguments, as raw command line arg strings, or via STDIN.<br />

Examples:<br />

java -Ddata=files -jar post.jar *.xml<br />

java -Ddata=args -jar post.jar '42'<br />

java -Ddata=stdin -jar post.jar < hd.xml<br />

Other options controlled by System Properties include the Solr URL to POST to, and whether a commit should be executed. These are the<br />

defaults for all System Properties:<br />

-Ddata=files<br />

-Durl=http://localhost:8983/<strong>solr</strong>/update<br />

-Dcommit=yes<br />

Go ahead and add all the documents in the directory as follows:<br />

$ java -Durl=http://localhost:8983/<strong>solr</strong>/update -jar post.jar *.xml<br />

SimplePostTool: version 1.2<br />

SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other<br />

encodings are not currently supported<br />

SimplePostTool: POSTing files to http://10.211.55.8:8983/<strong>solr</strong>/update..<br />

SimplePostTool: POSTing file hd.xml<br />

SimplePostTool: POSTing file ipod_other.xml<br />

SimplePostTool: POSTing file ipod_video.xml<br />

SimplePostTool: POSTing file mem.xml<br />

SimplePostTool: POSTing file monitor.xml<br />

SimplePostTool: POSTing file monitor2.xml<br />

SimplePostTool: POSTing file mp500.xml<br />

SimplePostTool: POSTing file sd500.xml<br />

SimplePostTool: POSTing file <strong>solr</strong>.xml<br />

SimplePostTool: POSTing file spellchecker.xml<br />

SimplePostTool: POSTing file utf8-example.xml<br />

SimplePostTool: POSTing file vidcard.xml<br />

SimplePostTool: COMMITting Solr index changes..<br />

Time spent: 0:00:00.633<br />

$<br />

That's it! Solr has indexed the documents contained in the files.<br />

Ask Questions<br />

Now that you have indexed documents, you can perform queries. The simplest way is by building a URL that includes the query parameters. This<br />

Apache Solr Reference Guide 4.6<br />

6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!