I'm not sure I understand how you are using Lucene without writing code, but here goes (NOT tested) String id = "123"; // this is the identifier String text = "this is some document text"; doc.add(new org.apache.lucene.document.Field("id",id, org.apache.lucene.document.Field.Store.YES, org.apache.lucene.document.Field.Index.UN_TOKENIZED)); doc.add(new org.apache.lucene.document.Field("text",text, org.apache.lucene.document.Field.Store.NO, org.apache.lucene.document.Field.Index.TOKENIZED)); iwriter.addDocument(doc); //iwriter is the indexWriter
The id gets stored in a field called "id", and the text in a field called "text" Then when you search you can IndexReader indexReader = IndexReader.open(directory); IndexSearcher isearcher = new IndexSearcher(directory); QueryParser parser = new QueryParser("text", analyzer); String term = "searchterm"; Query query = parser.parse(term); Hits hits = isearcher.search(query); for (int i=0; i< hits.length(); i++) { Document hitDoc = hits.doc(i); String id = hitDoc.get("id"); } Donna L. Gresh Services Research, Mathematical Sciences Department IBM T.J. Watson Research Center (914) 945-2472 http://www.research.ibm.com/people/g/donnagresh [EMAIL PROTECTED]