SOLR-164, use the SOLR-86 client in examples of the Solr tutorial

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@509455 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bertrand Delacretaz 2007-02-20 08:22:27 +00:00
parent beb009b8d8
commit 5ea4bd68b6
3 changed files with 467 additions and 466 deletions

View File

@ -183,27 +183,26 @@ To follow along with this tutorial, you will need...
<a href="http://java.sun.com/j2se/downloads.html">Sun</a>,
<a href="http://www-106.ibm.com/developerworks/java/jdk/">IBM</a>, or
<a href="http://www.bea.com/jrockit/">BEA</a>.
<br>
Running <span class="codefrag">java -version</span> at the command line should indicate a version
number starting with 1.5.
</li>
<li>A <a href="http://www.apache.org/dyn/closer.cgi/lucene/solr/">Solr release</a>.
</li>
<li>On Win32, <a href="http://www.cygwin.com/">cygwin</a>, for
shell support. (If you plan to use Subversion on Win32, be
sure to select the subversion package when you install, in the
"Devel" category.) This tutorial will assume that "<span class="codefrag">sh</span>"
is in your PATH, and that you have "curl" installed from the "Web" category.
<li>You'll need the <span class="codefrag">curl</span> utility to run the "delete documents" examples shown below.
</li>
<li>FireFox or Mozilla is the preferred browser to view the admin pages...
The current stylesheet doesn't look good on Internet Explorer.
<li>FireFox or Mozilla is the preferred browser to view the admin pages, as
the current stylesheet doesn't look good on Internet Explorer.
</li>
</ol>
</div>
<a name="N10047"></a><a name="Getting+Started"></a>
<a name="N10048"></a><a name="Getting+Started"></a>
<h2 class="boxed">Getting Started</h2>
<div class="section">
<p>
@ -216,10 +215,10 @@ Begin by unziping the Solr release and changing your working directory
to be the "<span class="codefrag">example</span>" directory. (Note that the base directory name may vary with the version of Solr downloaded.)
</p>
<pre class="code">
chrish@asimov:~/tmp/solr$ ls
chrish@asimov:~solr$ ls
solr-nightly.zip
chrish@asimov:~/tmp/solr$ unzip -q solr-nightly.zip
chrish@asimov:~/tmp/solr$ cd solr-nightly/example/
chrish@asimov:~solr$ unzip -q solr-nightly.zip
chrish@asimov:~solr$ cd solr-nightly/example/
</pre>
<p>
Solr can run in any Java Servlet Container of your choice, but to simplify
@ -229,11 +228,11 @@ this tutorial, the example index includes a small installation of Jetty. In ord
To launch Jetty with the Solr WAR, and the example configs, just run the <span class="codefrag">start.jar</span> ...
</p>
<pre class="code">
chrish@asimov:~/tmp/solr/solr-nightly/example$ java -jar start.jar
chrish@asimov:~/solr/example$ java -jar start.jar
1 [main] INFO org.mortbay.log - Logging to org.slf4j.impl.SimpleLogger@1f436f5 via org.mortbay.log.Slf4jLog
334 [main] INFO org.mortbay.log - Extract jar:file:/home/chrish/tmp/solr/solr-nightly/example/webapps/solr.war!/ to /tmp/Jetty__solr/webapp
334 [main] INFO org.mortbay.log - Extract jar:file:/home/chrish/solr/example/webapps/solr.war!/ to /tmp/Jetty__solr/webapp
Feb 24, 2006 5:54:52 PM org.apache.solr.servlet.SolrServlet init
INFO: user.dir=/home/chrish/tmp/solr/solr-nightly/example
INFO: user.dir=/home/chrish/solr/example
Feb 24, 2006 5:54:52 PM org.apache.solr.core.SolrConfig &lt;clinit&gt;
INFO: Loaded Config solrconfig.xml
@ -252,23 +251,36 @@ You can see that the Solr is running by loading <a href="http://localhost:8983/s
<a name="N10073"></a><a name="Indexing+Data"></a>
<a name="N10074"></a><a name="Indexing+Data"></a>
<h2 class="boxed">Indexing Data</h2>
<div class="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 <span class="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 "<span class="codefrag">curl</span>".
Your Solr server 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.
</p>
<p>
Open a new Terminal window, enter the exampledocs directory, and run the "<span class="codefrag">post.sh</span>" script on some of the XML files in that directory...
The <span class="codefrag">exampledocs</span> directory contains samples of the types of instructions Solr expects, as well as a java utility for posting
them from the command line (a <span class="codefrag">post.sh</span> shell script is also available, but for this tutorial we'll use the cross-platform Java
client).
</p>
<p>
To try this, open a new terminal window, enter the exampledocs directory, and run "<span class="codefrag">java -jar post.jar</span>" on some of the
XML files in that directory, indicating the URL of the Solr server:
</p>
<pre class="code">
chrish@asimov:~/tmp/solr/solr-nightly/example/exampledocs$ sh post.sh solr.xml
Posting file solr.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
&lt;result status="0"&gt;&lt;/result&gt;
chrish@asimov:~/solr/example/exampledocs$ java -jar post.jar http://localhost:8983/solr/update solr.xml monitor.xml
SimplePostTool: version 1.0
SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported
SimplePostTool: POSTing files to http://localhost:8983/solr/update..
SimplePostTool: POSTing file solr.xml
SimplePostTool: POSTing file monitor.xml
SimplePostTool: COMMITting Solr index changes..
SimplePostTool: 2 files POSTed to http://localhost:8983/solr/update
</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...
You have now indexed two documents in Solr, and committed these changes.
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...
</p>
<p>
@ -276,31 +288,26 @@ You have now indexed one document about Solr, and committed that change. You ca
</p>
<p>
You can index all of the sample data, using the following command...
You can index all of the sample data, using the following command (assuming your shell supports the *.xml notation):
</p>
<pre class="code">
chrish@asimov:~/tmp/solr/solr-nightly/example/exampledocs$ sh post.sh *.xml
Posting file hd.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;
Posting file ipod_other.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;
Posting file ipod_video.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file mem.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;
Posting file monitor.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file monitor2.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file mp500.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file sd500.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file solr.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file vidcard.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;
&lt;result status="0"&gt;&lt;/result&gt;
chrish@asimov:~/solr/example/exampledocs$ java -jar post.jar http://localhost:8983/solr/update *.xml
SimplePostTool: version 1.0
SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported
SimplePostTool: POSTing files to http://localhost:8983/solr/update..
SimplePostTool: POSTing file hd.xml
SimplePostTool: POSTing file ipod_other.xml
SimplePostTool: POSTing file ipod_video.xml
SimplePostTool: POSTing file mem.xml
SimplePostTool: POSTing file monitor.xml
SimplePostTool: POSTing file monitor2.xml
SimplePostTool: POSTing file mp500.xml
SimplePostTool: POSTing file sd500.xml
SimplePostTool: POSTing file solr.xml
SimplePostTool: POSTing file utf8-example.xml
SimplePostTool: POSTing file vidcard.xml
SimplePostTool: COMMITting Solr index changes..
SimplePostTool: 11 files POSTed to http://localhost:8983/solr/update
</pre>
<p>
...and now you can search for all sorts of things using the default <a href="http://lucene.apache.org/java/docs/queryparsersyntax.html">Lucene QueryParser syntax</a>...
@ -326,7 +333,7 @@ Posting file vidcard.xml to http://localhost:8983/solr/update
<a name="N100B7"></a><a name="Updating+Data"></a>
<a name="N100BB"></a><a name="Updating+Data"></a>
<h2 class="boxed">Updating Data</h2>
<div class="section">
<p>
@ -344,17 +351,17 @@ looking at the values for <span class="codefrag">numDocs</span> and <span class=
</p>
<p>
numDoc should be 16, 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.
numDoc should be 16 (because some of our 11 example XML files contain more than one <span class="codefrag">&lt;doc&gt;</span>), but maxDoc may be larger as
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.
Go ahead and edit the existing XML files to change some of the data, and re-run the <span class="codefrag">java -jar post.jar</span> command, you'll see your changes reflected in subsequent searches.
</p>
<a name="N100D9"></a><a name="Deleting+Data"></a>
<a name="N100E3"></a><a name="Deleting+Data"></a>
<h3 class="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
of the document's unique key field, or a query that matches multiple documents (be careful with that one!). 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>
@ -378,11 +385,11 @@ curl http://localhost:8983/solr/update --data-binary '&lt;commit/&gt;'
deleted documents to be removed. All of the update commands are documented <a href="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 <span class="codefrag">exampledocs</span> directory and executing</p>
<pre class="code">sh post.sh *.xml</pre>
<pre class="code">java -jar post.jar *.xml</pre>
</div>
<a name="N1011F"></a><a name="Querying+Data"></a>
<a name="N10129"></a><a name="Querying+Data"></a>
<h2 class="boxed">Querying Data</h2>
<div class="section">
<p>
@ -410,7 +417,7 @@ curl http://localhost:8983/solr/update --data-binary '&lt;commit/&gt;'
Solr provides a <a href="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>
<a name="N1014E"></a><a name="Sorting"></a>
<a name="N10158"></a><a name="Sorting"></a>
<h3 class="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...
@ -450,7 +457,7 @@ curl http://localhost:8983/solr/update --data-binary '&lt;commit/&gt;'
</div>
<a name="N10181"></a><a name="Text+Analysis"></a>
<a name="N1018B"></a><a name="Text+Analysis"></a>
<h2 class="boxed">Text Analysis</h2>
<div class="section">
<p>
@ -494,7 +501,7 @@ curl http://localhost:8983/solr/update --data-binary '&lt;commit/&gt;'
<p>A full description of the analysis components, Analyzers, Tokenizers, and TokenFilters
available for use is <a href="http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters">here</a>.
</p>
<a name="N101D8"></a><a name="Analysis+Debugging"></a>
<a name="N101E2"></a><a name="Analysis+Debugging"></a>
<h3 class="boxed">Analysis Debugging</h3>
<p>There is a handy <a href="http://localhost:8983/solr/admin/analysis.jsp">analysis</a>
debugging page where you can see how a text value is broken down into words,
@ -523,7 +530,7 @@ curl http://localhost:8983/solr/update --data-binary '&lt;commit/&gt;'
</div>
<a name="N10217"></a><a name="Conclusion"></a>
<a name="N10221"></a><a name="Conclusion"></a>
<h2 class="boxed">Conclusion</h2>
<div class="section">
<p>

File diff suppressed because it is too large Load Diff

View File

@ -49,17 +49,16 @@ To follow along with this tutorial, you will need...
<a href="http://java.sun.com/j2se/downloads.html">Sun</a>,
<a href="http://www-106.ibm.com/developerworks/java/jdk/">IBM</a>, or
<a href="http://www.bea.com/jrockit/">BEA</a>.
<br/>
Running <code>java -version</code> at the command line should indicate a version
number starting with 1.5.
</li>
<li>A <a href="http://www.apache.org/dyn/closer.cgi/lucene/solr/">Solr release</a>.
</li>
<li>On Win32, <a href="http://www.cygwin.com/">cygwin</a>, for
shell support. (If you plan to use Subversion on Win32, be
sure to select the subversion package when you install, in the
"Devel" category.) This tutorial will assume that "<code>sh</code>"
is in your PATH, and that you have "curl" installed from the "Web" category.
<li>You'll need the <code>curl</code> utility to run the "delete documents" examples shown below.
</li>
<li>FireFox or Mozilla is the preferred browser to view the admin pages...
The current stylesheet doesn't look good on Internet Explorer.
<li>FireFox or Mozilla is the preferred browser to view the admin pages, as
the current stylesheet doesn't look good on Internet Explorer.
</li>
</ol>
</section>
@ -74,10 +73,10 @@ Begin by unziping the Solr release and changing your working directory
to be the "<code>example</code>" directory. (Note that the base directory name may vary with the version of Solr downloaded.)
</p>
<source>
chrish@asimov:~/tmp/solr$ ls
chrish@asimov:~solr$ ls
solr-nightly.zip
chrish@asimov:~/tmp/solr$ unzip -q solr-nightly.zip
chrish@asimov:~/tmp/solr$ cd solr-nightly/example/
chrish@asimov:~solr$ unzip -q solr-nightly.zip
chrish@asimov:~solr$ cd solr-nightly/example/
</source>
<p>
@ -89,11 +88,11 @@ To launch Jetty with the Solr WAR, and the example configs, just run the <code>s
</p>
<source>
chrish@asimov:~/tmp/solr/solr-nightly/example$ java -jar start.jar
chrish@asimov:~/solr/example$ java -jar start.jar
1 [main] INFO org.mortbay.log - Logging to org.slf4j.impl.SimpleLogger@1f436f5 via org.mortbay.log.Slf4jLog
334 [main] INFO org.mortbay.log - Extract jar:file:/home/chrish/tmp/solr/solr-nightly/example/webapps/solr.war!/ to /tmp/Jetty__solr/webapp
334 [main] INFO org.mortbay.log - Extract jar:file:/home/chrish/solr/example/webapps/solr.war!/ to /tmp/Jetty__solr/webapp
Feb 24, 2006 5:54:52 PM org.apache.solr.servlet.SolrServlet init
INFO: user.dir=/home/chrish/tmp/solr/solr-nightly/example
INFO: user.dir=/home/chrish/solr/example
Feb 24, 2006 5:54:52 PM org.apache.solr.core.SolrConfig &lt;clinit&gt;
INFO: Loaded Config solrconfig.xml
@ -117,53 +116,61 @@ You can see that the Solr is running by loading <a href="http://localhost:8983/s
<title>Indexing Data</title>
<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 <code>exampledocs</code> directory contains samples of the types of instructions Solr expects, as well as a Shell script for posting them using the command line utility "<code>curl</code>".
Your Solr server 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.
</p>
<p>
Open a new Terminal window, enter the exampledocs directory, and run the "<code>post.sh</code>" script on some of the XML files in that directory...
The <code>exampledocs</code> directory contains samples of the types of instructions Solr expects, as well as a java utility for posting
them from the command line (a <code>post.sh</code> shell script is also available, but for this tutorial we'll use the cross-platform Java
client).
</p>
<p>
To try this, open a new terminal window, enter the exampledocs directory, and run "<code>java -jar post.jar</code>" on some of the
XML files in that directory, indicating the URL of the Solr server:
</p>
<source>
chrish@asimov:~/tmp/solr/solr-nightly/example/exampledocs$ sh post.sh solr.xml
Posting file solr.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
&lt;result status="0"&gt;&lt;/result&gt;
chrish@asimov:~/solr/example/exampledocs$ java -jar post.jar http://localhost:8983/solr/update solr.xml monitor.xml
SimplePostTool: version 1.0
SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported
SimplePostTool: POSTing files to http://localhost:8983/solr/update..
SimplePostTool: POSTing file solr.xml
SimplePostTool: POSTing file monitor.xml
SimplePostTool: COMMITting Solr index changes..
SimplePostTool: 2 files POSTed to http://localhost:8983/solr/update
</source>
<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...
You have now indexed two documents in Solr, and committed these changes.
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...
</p>
<p>
<a href="http://localhost:8983/solr/select/?stylesheet=&amp;q=solr&amp;version=2.1&amp;start=0&amp;rows=10&amp;indent=on">http://localhost:8983/solr/select/?stylesheet=&amp;q=solr&amp;version=2.1&amp;start=0&amp;rows=10&amp;indent=on</a>
</p>
<p>
You can index all of the sample data, using the following command...
You can index all of the sample data, using the following command (assuming your shell supports the *.xml notation):
</p>
<source>
chrish@asimov:~/tmp/solr/solr-nightly/example/exampledocs$ sh post.sh *.xml
Posting file hd.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;
Posting file ipod_other.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;
Posting file ipod_video.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file mem.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;
Posting file monitor.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file monitor2.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file mp500.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file sd500.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file solr.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;
Posting file vidcard.xml to http://localhost:8983/solr/update
&lt;result status="0"&gt;&lt;/result&gt;&lt;result status="0"&gt;&lt;/result&gt;
&lt;result status="0"&gt;&lt;/result&gt;
chrish@asimov:~/solr/example/exampledocs$ java -jar post.jar http://localhost:8983/solr/update *.xml
SimplePostTool: version 1.0
SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported
SimplePostTool: POSTing files to http://localhost:8983/solr/update..
SimplePostTool: POSTing file hd.xml
SimplePostTool: POSTing file ipod_other.xml
SimplePostTool: POSTing file ipod_video.xml
SimplePostTool: POSTing file mem.xml
SimplePostTool: POSTing file monitor.xml
SimplePostTool: POSTing file monitor2.xml
SimplePostTool: POSTing file mp500.xml
SimplePostTool: POSTing file sd500.xml
SimplePostTool: POSTing file solr.xml
SimplePostTool: POSTing file utf8-example.xml
SimplePostTool: POSTing file vidcard.xml
SimplePostTool: COMMITting Solr index changes..
SimplePostTool: 11 files POSTed to http://localhost:8983/solr/update
</source>
<p>
@ -197,18 +204,18 @@ looking at the values for <code>numDocs</code> and <code>maxDoc</code> in the
</p>
<p>
numDoc should be 16, 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.
numDoc should be 16 (because some of our 11 example XML files contain more than one <code>&lt;doc&gt;</code>), but maxDoc may be larger as
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.
Go ahead and edit the existing XML files to change some of the data, and re-run the <code>java -jar post.jar</code> command, you'll see your changes reflected in subsequent searches.
</p>
<section>
<title>Deleting Data</title>
<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
of the document's unique key field, or a query that matches multiple documents (be careful with that one!). 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>
@ -234,7 +241,7 @@ curl http://localhost:8983/solr/update --data-binary '&lt;commit/>'
</p>
<p>To continue with the tutorial, re-add any documents you may have deleted by going to the <code>exampledocs</code> directory and executing</p>
<source>sh post.sh *.xml</source>
<source>java -jar post.jar *.xml</source>
</section>