• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Apache Lucene 3.6.1

Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 = indexSearcher.search(query);//arguments do not match

Posts: 43011
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!