home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Lucene example source code file (demo.xml)

This example Lucene source code file (demo.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Lucene tags/keywords

about, about, classpath, classpath, demo, document, files, jar, lucene, lucene, the, you, you, you'll

The Lucene demo.xml source code

<?xml version="1.0"?>
<document>
	<header>
        <title>
	Apache Lucene - Building and Installing the Basic Demo
		</title>
	</header>
<properties>
<author email="acoliver@apache.org">Andrew C. Oliver
</properties>
<body>

<section id="About this Document">About this Document
<p>
This document is intended as a "getting started" guide to using and running the Lucene demos.
It walks you through some basic installation and configuration.
</p>
</section>


<section id="About the Demo">About the Demo
<p>
The Lucene command-line demo code consists of an application that demonstrates various
functionalities of Lucene and how you can add Lucene to your applications.
</p>
</section>

<section id="Setting your CLASSPATH">Setting your CLASSPATH
<p>
First, you should <a href="http://www.apache.org/dyn/closer.cgi/lucene/java/">download the
latest Lucene distribution and then extract it to a working directory.
</p>
<p>
You need two JARs: the Lucene JAR, and the Lucene demo JAR.  You should
see the Lucene JAR file in the directory you created when you extracted the archive -- it
should be named something like <code>lucene-core-{version}.jar.  You should also see a file
called <code>contrib/demo/lucene-demo-{version}.jar.
</p>
<p>
Put both of these files in your Java CLASSPATH.
</p>
</section>

<section id="Indexing Files">Indexing Files
<p>
Once you've gotten this far you're probably itching to go.  Let's <b>build an index! Assuming
you've set your CLASSPATH correctly, just type:

<pre>
    java org.apache.lucene.demo.IndexFiles -docs {path-to-lucene}/src
</pre>

This will produce a subdirectory called <code>index which will contain an index of all of the
Lucene source code.
</p>
<p>
To <b>search the index type:

<pre>
    java org.apache.lucene.demo.SearchFiles
</pre>

You'll be prompted for a query.  Type in a swear word and press the enter key.  You'll see that the
Lucene developers are very well mannered and get no results. Now try entering the word "string".
That should return a whole bunch of documents.  The results will page at every tenth result and ask
you whether you want more results.
</p>
</section>

<section id="About the code...">About the code...
<p>
<a href="demo2.html">read on>>>
</p>
</section>

</body>
</document>

Other Lucene examples (source code examples)

Here is a short list of links related to this Lucene demo.xml source code file:



my book on functional programming

 

new blog posts

 

Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.