首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

运作lucene-3.6.1中Demo示例时的注意点

2012-09-25 
运行lucene-3.6.1中Demo示例时的注意点First, you should download the latest Lucene distribution and t

运行lucene-3.6.1中Demo示例时的注意点

First, you should download the latest Lucene distribution and then extract it to a working directory.

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 lucene-core-{version}.jar. You should also see a file called contrib/demo/lucene-demo-{version}.jar.

Put both of these files in your Java CLASSPATH.

Indexing Files

Once you've gotten this far you're probably itching to go. Let's build an index! Assuming you've set your CLASSPATH correctly, just type:

    java org.apache.lucene.demo.IndexFiles -docs {path-to-lucene}/src
This will produce a subdirectory called index which will contain an index of all of the Lucene source code. 注:运行这个命令:1、假设所有的配置都已完成2、直接打开cmd ,输入java org.apache.lucene.demo.IndexFiles -docs  {path-to-lucene}/src(这个参数是指定你想要对其建立索引的目录,不一定非得指定lucene/src目录,我用的lucene-3.6.1根本没有src目录),它会在当前路径下建立index目录来存储索引,我这里是在C:\Documents and Settings\Administrator目录下建立index文件。     例:C:\Documents and Settings\Administrator>java org.apache.lucene.demo.IndexFiles -docs D:/hcy运作lucene-3.6.1中Demo示例时的注意点  3、接下来so easy! 

To search the index type:

    java org.apache.lucene.demo.SearchFiles
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.About the code...

read on>>>

热点排行