eclipse 导入 lucence源码

在网上搜了几个都是过时的讲述,还是从google上找到了一个邮件,虽然写的很简陋但是真的好使了。

 

步骤很简单:

1. 下载 lucence 源码:

    https://lucene.apache.org/core/index.html

     点击下载,在点击对应的镜像url之后会看到类似ftp的东西,选择对应的源码。例如我选择的是:

     http://mirrors.cnnic.cn/apache/lucene/java/5.1.0/

     lucene-5.1.0-src.tgz

     之后解压。

     

2.   打开eclipse,创建一个普通的java工程,里面是空的,只有src空目录。

 

3.   右击 src,选择import, 选择 General-->File System 然后点击对话框下面的Next。进入另外一个对话框,在这个选择框里选择 刚才解压的目录,然后选择 core/src/java  这个目录。然后点击对话框最下面的Finish即可。这时候顺利的话就会成功导入了。

 


eclipse 导入 lucence源码
 
eclipse 导入 lucence源码

 

 

4. 好,那么然后呢?

我在导入的时候看到有部分有红色的叉,仔细看是说不支持jre 1.7之下的环境,需要切换成jre1.7环境,由于已经装了jre1.7 ,由于eclipse 创建项目时默认是低版本的,所以有这个问题,点击他的提示之后就自动修复好了。至此,lucence core就导入完事了。

那么,问题来了,lucence还有许多文件我还没导啊,原来解压的那个文件夹下面有一堆的文件夹呢。

别急,看完core之后就可以一个个使用类似方法导入一点点看了。

在core/src/java下有一个overview.html 可以看到:

 

The Lucene API is divided into several packages:

  • {@link org.apache.lucene.analysis} defines an abstract {@link org.apache.lucene.analysis.Analyzer Analyzer} API for converting text from a {@link java.io.Reader} into a {@link org.apache.lucene.analysis.TokenStream TokenStream}, an enumeration of token {@link org.apache.lucene.util.Attribute Attribute}s.  A TokenStream can be composed by applying {@link org.apache.lucene.analysis.TokenFilter TokenFilter}s to the output of a {@link org.apache.lucene.analysis.Tokenizer Tokenizer}.  Tokenizers and TokenFilters are strung together and applied with an {@link org.apache.lucene.analysis.Analyzer Analyzer}.  analyzers-common provides a number of Analyzer implementations, including StopAnalyzer and the grammar-based StandardAnalyzer.
  • {@link org.apache.lucene.codecs} provides an abstraction over the encoding and decoding of the inverted index structure, as well as different implementations that can be chosen depending upon application needs.
  • {@link org.apache.lucene.document} provides a simple {@link org.apache.lucene.document.Document Document} class.  A Document is simply a set of named {@link org.apache.lucene.document.Field Field}s, whose values may be strings or instances of {@link java.io.Reader}.
  • {@link org.apache.lucene.index} provides two primary classes: {@link org.apache.lucene.index.IndexWriter IndexWriter}, which creates and adds documents to indices; and {@link org.apache.lucene.index.IndexReader}, which accesses the data in the index.
  • {@link org.apache.lucene.search} provides data structures to represent queries (ie {@link org.apache.lucene.search.TermQuery TermQuery} for individual words, {@link org.apache.lucene.search.PhraseQuery PhraseQuery} for phrases, and {@link org.apache.lucene.search.BooleanQuery BooleanQuery} for boolean combinations of queries) and the {@link org.apache.lucene.search.IndexSearcher IndexSearcher} which turns queries into {@link org.apache.lucene.search.TopDocs TopDocs}. A number of QueryParsers are provided for producing query structures from strings or xml.
  • {@link org.apache.lucene.store} defines an abstract class for storing persistent data, the {@link org.apache.lucene.store.Directory Directory}, which is a collection of named files written by an {@link org.apache.lucene.store.IndexOutput IndexOutput} and read by an {@link org.apache.lucene.store.IndexInput IndexInput}.  Multiple implementations are provided, including {@link org.apache.lucene.store.FSDirectory FSDirectory}, which uses a file system directory to store files, and {@link org.apache.lucene.store.RAMDirectory RAMDirectory} which implements files as memory-resident data structures.
  • {@link org.apache.lucene.util} contains a few handy data structures and util classes, ie {@link org.apache.lucene.util.FixedBitSet FixedBitSet} and {@link org.apache.lucene.util.PriorityQueue PriorityQueue}.

 

 

 

 

 

你可能感兴趣的:(eclipse)