[Lucene] membaca field


Membaca Field di dalam Lucene dimana field tiap dokumen bersifat statis.

final NIOFSDirectory  dir = new NIOFSDirectory(new File(this.Dir));
        final IndexReader reader = IndexReader.open(dir, true);
        final Collection fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
        for (int i = 0; i < reader.numDocs(); i++)
        {
            System.out.println("processing document "+i);
            final Iterator fieldnameIT = fieldNames.iterator();
            final Document document = reader.document(i);
            while (fieldnameIT.hasNext())
            {  final String fieldname = fieldnameIT.next().toString();
               System.out.println(fieldname+" "+document.get(fieldname));
            }
        }

always happy coding🙂

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s