lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel de Souza Teixeira" <dan...@ccuec.unicamp.br>
Subject How to use PhraseQuery Class?
Date Tue, 15 Jun 2004 15:21:38 GMT
Hi!
I need some information about PhraseQuery Class.

How to use this class ?

I tried to use, but I couldn't.
I created an index, just with 2 fields:
   - path: path of the file
   - contents: the text of the file (pdf,txt,html,doc,rtf ...)

I want to search with phrases... Is it possible ?

This is te code...

public void indexFiles(String filePath, String documentText, String
indexName, boolean create) {

	try {


		IndexWriter writer = null;

		File index = new File ("./" + indexName);

		if (!index.exists()) {
			writer = new IndexWriter(indexName, null, true);
			writer.optimize();
			writer.close();
		}

		writer = new IndexWriter(indexName, new StandardAnalyzer(), false);

		Document doc = new Document();

		doc.add(Field.UnIndexed ("path",filePath));
		doc.add(Field.Text("contents",documentText));

		writer.addDocument(doc);

		doc = null;
		writer.close();
	}

	catch (Exception ex) {
		System.out.println("Error - " + ex);
	}

}

Thanks!

Regards.

-- 
Daniel de Souza Teixeira
Laboratório de Inovação em Software - Unicamp/Ci&T
Campinas-SP
Brasil



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message