1

I am using lucene for indexing and searching on client side after searching the keyword i want to display the html files there . So is there any way to store and access the html files . actually the html files are storing images and links and they should be opened in the java api as normal html file . I am using the following code for lucene indexing

  try
  {

        IndexWriter indexWriter = new IndexWriter(

        FSDirectory.open(indexDir),

        new SimpleAnalyzer(),

        true,
        IndexWriter.MaxFieldLength.LIMITED);
        indexWriter.setUseCompoundFile(false);
        indexDirectory(indexWriter, dataDir, suffix);

        Document doc = new Document();

        doc.add(new Field("contents", new FileReader(f))); 

        doc.add(new Field("filename",f.getCanonicalPath(),

        Field.Store.YES,Field.Index.ANALYZED));
        indexWriter.addDocument(doc);

        numIndexed = indexWriter.maxDoc();

        indexWriter.optimize();

        indexWriter.close();

        } 

        catch(Exception ex)
        {
        }

How should i display the html files matching the search criteria on client side

Guillaume Polet
  • 47,259
  • 4
  • 83
  • 117
adesh kumar
  • 129
  • 3
  • 10
  • As written (and even after edits), your question is indecipherable. What HTML files? How are these files added to Lucene, and where are they stored? Are you talking about a desktop (Swing) client, or a web client? Does the client have access to the original files? – parsifal Oct 01 '12 at 19:44
  • 1
    My recommendation is that you step back and draw out a block diagram of your application, and then ask your question again. And unless that code is somehow specific to your question (it looks like generic code to add a document to a Lucene index), just remove it. – parsifal Oct 01 '12 at 19:45

1 Answers1

3

You may be looking for browse(), which "Launches the default browser to display a URI." Alternatively, an editor pane can be used, although support is limited.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045