<inputvalue="incubator.apache.org"name="sitesearch"type="hidden"><inputonFocus="getBlank (this, 'Search the site with google');"size="25"name="q"id="query"type="text"value="Search the site with google">
Feb 24, 2006 5:54:52 PM org.apache.solr.core.SolrConfig <clinit>
INFO: Loaded Config solrconfig.xml
...
1656 [main] INFO org.mortbay.log - Started SelectChannelConnector @ 0.0.0.0:8983
</pre>
<p>
This will start up the Jetty application server on port 8983, and use your terminal to display the logging information from Solr.
</p>
<p>
You can see that the Solr is running by loading <ahref="http://localhost:8983/solr/admin/">http://localhost:8983/solr/admin/</a> in your web browser. This is the main starting point for Administering Solr.
</p>
</div>
<aname="N1006E"></a><aname="Indexing+Data"></a>
<h2class="boxed">Indexing Data</h2>
<divclass="section">
<p>
Your Solr port is up and running, but it doesn't contain any data. You can modify a Solr index by POSTing XML Documents containing instructions to add (or update) documents, delete documents, commit pending adds and deletes, and optimize your index. The <spanclass="codefrag">exampledocs</span> directory contains samples of the types of instructions Solr expects, as well as a Shell script for posting them using the command line utility "<spanclass="codefrag">curl</span>".
</p>
<p>
Open a new Terminal window, enter the exampledocs directory, and run the "<spanclass="codefrag">post.sh</span>" script on some of the XML files in that directory...
</p>
<preclass="code">
chrish@asimov:~/tmp/solr/solr-1.0/example/exampledocs$ sh post.sh solr.xml
Posting file solr.xml to http://localhost:8983/solr/update
<result status="0"></result>
<result status="0"></result>
</pre>
<p>
You have now indexed one document about Solr, and committed that change. You can now search for "solr" using the "Make a Query" interface on the Admin screen, and you should get one result. Clicking the "Search" button should take you to the following URL...
...and now you can search for all sorts of things using the default <ahref="http://lucene.apache.org/java/docs/queryparsersyntax.html">Lucene QueryParser syntax</a>...
numDoc should be 15, but maxDoc may be larger (the maxDoc count includes logically deleted documents that have not yet been removed from the index). You can re-post the sample XML
files over and over again as much as you want and numDocs will never increase,
because the new documents will constantly be replacing the old.
</p>
<p>
Go ahead and edit the existing XML files to change some of the data, and re-run the post.sh command, you'll see your changes reflected in subsequent searches.
</p>
<aname="N100D4"></a><aname="Deleting+Data"></a>
<h3class="boxed">Deleting Data</h3>
<p>You can delete data by POSTing a delete command to the update URL and specifying the value
of the document's unique key field, or a query that matches multiple documents. Since these commands
are smaller, we will specify them right on the command line rather than reference an XML file.
</p>
<p>Execute the following command to delete a document</p>
<p>Commit can be a very expensive operation so it's best to make many changes to an index in a batch and
then send the commit command at the end. There is also an optimize command that does the same thing as commit,
in addition to merging all index segments into a single segment, making it faster to search and causing any
deleted documents to be removed. All of the update commands are documented <ahref="http://wiki.apache.org/solr/UpdateXmlMessages">here</a>.
</p>
<p>To continue with the tutorial, re-add any documents you may have deleted by going to the <spanclass="codefrag">exampledocs</span> directory and executing</p>
<preclass="code">sh post.sh *.xml</pre>
</div>
<aname="N1011A"></a><aname="Querying+Data"></a>
<h2class="boxed">Querying Data</h2>
<divclass="section">
<p>
Searches are done via HTTP GET on the select URL with the query string in the q parameter.
You can pass a number of optional <ahref="http://wiki.apache.org/solr/StandardRequestHandler">request parameters</a>
to the request handler to control what information is returned. For example, you can use the "fl" parameter
to control what stored fields are returned, and if the relevancy score is returned...
</p>
<ul>
<li>
<ahref="http://localhost:8983/solr/select/?indent=on&q=video&fl=name,id">q=video&fl=name,id</a> (return only name and id fields) </li>
<li>
<ahref="http://localhost:8983/solr/select/?indent=on&q=video&fl=name,id,score">q=video&fl=name,id,score</a> (return relevancy score as well) </li>
<li>
<ahref="http://localhost:8983/solr/select/?indent=on&q=video&fl=*,score">q=video&fl=*,score</a> (return all stored fields, as well as relevancy score) </li>
Solr provides a <ahref="http://localhost:8983/solr/admin/form.jsp">query form</a> within the web admin interface
that allows setting the various request parameters and is useful when trying out or debugging queries.
</p>
<aname="N10149"></a><aname="Sorting"></a>
<h3class="boxed">Sorting</h3>
<p>
Solr provides a simple extension to the Lucene QueryParser syntax for specifying sort options. After your search, add a semi-colon followed by a list of "field direction" pairs...
shows how "<spanclass="codefrag">Canon PowerShot SD500</span>" would be indexed as a value in the name field. Each row of
the table shows the resulting tokens after having passed through the next TokenFilter in the Analyzer for the <spanclass="codefrag">name</span> field.
Notice how both <spanclass="codefrag">powershot</span> and <spanclass="codefrag">power</span>, <spanclass="codefrag">shot</span> are indexed. Tokens generated at the same position
are shown in the same column, in this case <spanclass="codefrag">shot</span> and <spanclass="codefrag">powershot</span>.