LUCENE-909: Demo targets for running the demo.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@544685 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doron Cohen 2007-06-05 23:52:05 +00:00
parent 8c62eb41a4
commit 1de7b02e98
3 changed files with 94 additions and 3 deletions

View File

@ -265,6 +265,8 @@ Build
6. LUCENE-907: Include LICENSE.TXT and NOTICE.TXT in the META-INF dirs of
demo war, demo jar, and the contrib jars. (Michael Busch)
7. LUCENE-909: Demo targets for running the demo. (Doron Cohen)
======================= Release 2.1.0 2007-02-14 =======================

View File

@ -90,9 +90,72 @@
<target name="clean"
description="Removes contents of build directory">
<delete dir="${build.dir}"/>
<delete dir="${common.dir}/demo-text-dir"/>
<delete dir="${common.dir}/demo-html-dir"/>
</target>
<!-- ================================================================== -->
<!-- R U N T E X T I N D E X I N G D E M O -->
<!-- ================================================================== -->
<!-- -->
<!-- ================================================================== -->
<target name="demo-index-text" depends="jar-demo"
description="Run text indexing demo (index the sources of the demo).">
<echo>----- (1) Prepare dir ----- </echo>
<echo>cd ${common.dir} </echo>
<echo>rmdir demo-text-dir </echo>
<delete dir="${common.dir}/demo-text-dir"/>
<echo>mkdir demo-text-dir </echo>
<mkdir dir="${common.dir}/demo-text-dir"/>
<echo>cd demo-text-dir </echo>
<echo>----- (2) Index the files located under ${common.dir}/src ----- </echo>
<invoke-java class="IndexFiles" params="${common.dir}/src/demo" paramsDisplay="../src/demo" type="text"/>
</target>
<!-- ================================================================== -->
<!-- R U N T E X T S E A R C H D E M O -->
<!-- ================================================================== -->
<!-- -->
<!-- ================================================================== -->
<target name="demo-search-text" depends="jar-demo"
description="Run interactive search demo.">
<echo>----- Interactive search ----- </echo>
<echo>cd demo-text-dir </echo>
<invoke-java class="SearchFiles" params="-index index" paramsDisplay="-index index" type="text"/>
</target>
<!-- ================================================================== -->
<!-- R U N H T M L I N D E X I N G D E M O -->
<!-- ================================================================== -->
<!-- -->
<!-- ================================================================== -->
<target name="demo-index-html" depends="jar-demo"
description="Run html indexing demo (index the javadocs).">
<echo>----- (1) Prepare dir ----- </echo>
<echo>cd ${common.dir} </echo>
<echo>rmdir demo-html-dir </echo>
<delete dir="${common.dir}/demo-html-dir"/>
<echo>mkdir demo-html-dir </echo>
<mkdir dir="${common.dir}/demo-html-dir"/>
<echo>cd demo-html-dir </echo>
<echo>----- (2) Index the files located under ${common.dir}/src ----- </echo>
<invoke-java class="IndexFiles" params="${common.dir}/docs/api" paramsDisplay="../docs/api" type="html"/>
</target>
<!-- ================================================================== -->
<!-- R U N H T M L S E A R C H D E M O -->
<!-- ================================================================== -->
<!-- -->
<!-- ================================================================== -->
<target name="demo-search-html" depends="jar-demo"
description="Run interactive search demo.">
<echo>----- Interactive search ----- </echo>
<echo>cd demo-html-dir </echo>
<invoke-java class="SearchFiles" params="-index index" paramsDisplay="-index index" type="html"/>
</target>
<!--+
| M A C R O S
+-->
@ -115,4 +178,26 @@
</sequential>
</macrodef>
<macrodef name="invoke-java">
<attribute name="class"/>
<attribute name="params"/>
<attribute name="paramsDisplay"/>
<attribute name="type"/>
<sequential>
<echo>java -classpath "../${core.name}.jar;../${demo.name}.jar" org.apache.lucene.demo.@{class} @{paramsDisplay} </echo>
<java classname="org.apache.lucene.demo.@{class}"
dir="${common.dir}/demo-@{type}-dir"
fork="true"
failonerror="true"
maxmemory="128m"
>
<arg value="@{params}"/>
<classpath>
<pathelement location="${common.dir}/${core.name}.jar"/>
<pathelement location="${common.dir}/${demo.name}.jar"/>
</classpath>
</java>
</sequential>
</macrodef>
</project>

View File

@ -111,13 +111,17 @@ public class SearchFiles {
QueryParser parser = new QueryParser(field, analyzer);
while (true) {
if (queries == null) // prompt the user
System.out.print("Query: ");
System.out.println("Enter query: ");
String line = in.readLine();
if (line == null || line.length() == -1)
break;
line = line.trim();
if (line.length() == 0)
break;
Query query = parser.parse(line);
System.out.println("Searching for: " + query.toString(field));
@ -161,7 +165,7 @@ public class SearchFiles {
break;
if (hits.length() > end) {
System.out.print("more (y/n) ? ");
System.out.println("more (y/n) ? ");
line = in.readLine();
if (line.length() == 0 || line.charAt(0) == 'n')
break;