If i understand the requirement correctly, contract is one document in your system which in turn contains some *'n*' fields. Contract_ID is the key in all the documents(Structures). Contract_ID is the only field you want to retrieve no matter on what field you search for. If this is the case, store and index Contract_ID for each document and just index the rest of the fields.
This way the documents returned when you search will only contain Contract_ID. On Tue, Jun 7, 2011 at 11:06 AM, Pranav goyal <pranavgoyal40...@gmail.com>wrote: > 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(FSDirectory.open(indexDir), > analyzer, IndexWriter.MaxFieldLength.UNLIMITED); > } > catch (IOException e1) { > e1.printStackTrace(); > } > > 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, > Field.Index.NO)); > try { > writer.addDocument(d); > writer.optimize() ; > writer.close(); > } > catch (IOException e1) { > e1.printStackTrace(); > } > } > > In the end what I want to get is the Contract_ID whenever I search for > anything. > 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? > -- Thanks and Regards, DakshinaMurthy BM