File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes Apache Lucene 3.6.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Apache Lucene 3.6.1" Watch "Apache Lucene 3.6.1" New topic

Apache Lucene 3.6.1

Singh Kuldeep

Joined: Jul 18, 2012
Posts: 19
Hi every body. I want to use apache lucene 3.6.1 api for indexed search. I download jar files, and an example. In that example I am facing the problems described in comments in corresponding line.
Please help where I am going wrong. do i need to download some others jar file besides lucene-core-3.6.1.jar, lucene-core-3.6.1-javadoc.jar, lucene-test-framework-3.6.1.jar, lucene-test-framework-3.6.1.jar

Analyzer analyzer = new StandardAnalyzer();// default constructor is not available
IndexWriter indexWriter = new IndexWriter(INDEX_DIRECTORY, analyzer, recreateIndexIfExists);// recreateIndexifExist is a boolean variable

document.add(new Field(FIELD_PATH, path, Field.Store.YES, Field.Index.UN_TOKENIZED));//Field.Index.UN_TOKENIZED not resolved
Directory directory = FSDirectory.getDirectory(INDEX_DIRECTORY);//getDirectory() not resolved

QueryParser queryParser = new QueryParser(FIELD_CONTENTS, analyzer);//arguments do not match
Hits hits =;//arguments do not match

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
lucene-core-3.6.1.jar is the only file you need for compiling and running.

StandardAnalyzer does not have a no-argument constructor.

Field.Index.UN_TOKENIZED does not exist.

The FSDirectory.getDirectory method takes no parameters.

QueryParser does not have a constructor that takes two parameters.

All this is exactly as stated in the respective javadocs. Are you possibly looking at javadocs for an obsolete version of Lucene? If so, note that Lucene is different from most libraries in that it is *not* backwards-compatible; code written against version X of Lucene frequently needs to be refactored to work with version X+1.
I agree. Here's the link:
subject: Apache Lucene 3.6.1
jQuery in Action, 3rd edition