On Jun 15, 2004, at 11:21 AM, Daniel de Souza Teixeira wrote:
Hi!
I need some information about PhraseQuery Class.

How to use this class ?

Are you using QueryParser to create the query? If so, have a look at the query parser syntax page in the docs (or the Lucene website) - basically just surround the phase with double-quotes - "this is some phrase".


If you are using PhraseQuery directly, have a look at Lucene's own JUnit test cases (notice a trend here of me pointing folks to the test cases for documentation?! :) Here's a copy/paste:

    Query query = new PhraseQuery();
    query.setSlop(2);
    query.add(new Term("field", "one"));
    query.add(new Term("field", "five"));

Erik





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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to