lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pranav goyal <>
Subject Lucene Indexing
Date Tue, 07 Jun 2011 05:36:00 GMT
Hi all,

Got stuck at a place and not able to think what should I do.
I have one structure which I have to index. Let say the structure name is
Contract which has a unique Contract_ID. Let say I have 50 contracts which I
have to index.

Now each contract has let say 100 different keys with their values.

For example

key is ->Contract_ID Value is 0000324123
key is ->ContractDomain...Value is GOV
key is ->CtrtSubType...Value is PUB_TENDER[40]
key is ->DocStatus...Value is Off.DFT[1]
key is ->GenericBrandType...Value is BRND[2]
key is ->CustomerContactInfo...Value is 9346831616

like this there are 95 more keys with their values in each contract.

Now I have to index *all the contracts*.
How should I make my index?

StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_31);
                IndexWriter writer = null;
                File indexDir = new File("./indexDir");
                try {
                        writer = new IndexWriter(,
analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
                catch (IOException e1) {

Document d = new Document();
d.add(new Field("key", key , Field.Store.YES , Field.Index.ANALYZED));
d.add(new Field("attribute",attribute.toString(), Field.Store.YES,
try {
                        writer.optimize() ;
                catch (IOException e1) {

In the end what I want to get is the Contract_ID whenever I search for
Please help me out. I am in a fix. Whether I am indexing it the right way or
I should do it the other way?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message