tags:

views:

46

answers:

1

Hello, I'm trying to figure out the right way to read lucene index only once whilst running the application multiple times, how can I do that in java?

Because indexed data will not change so reading them each time would not be necessary. Can someone explain me the logic of it reading them only once? thank you

UPDATE :

public List initTableObject() throws IOException {
        Directory fSDirectory = FSDirectory.open(new File(INDEX_NAME));
        List<String>termList = new ArrayList<String>();

        RAMDirectory directory = new RAMDirectory(fSDirectory);

        IndexReader iReader = IndexReader.open(fSDirectory);
        FilterIndexReader fReader = new FilterIndexReader(iReader);



    //  int numOfDocs = fReader.numDocs();
        TermEnum terms = fReader.terms(); 


        while (terms.next()){
            Term term = terms.term(); 
            String termText = term.text();
            termList.add(termText);
            }
            iReader.close();
            return termList;
    }

I'm really new with lucene and this, so here is what I've got so far I'm just not there yet with RAMDirectory.

This method retrieves list because I need this index list to compare with some files that I have. How can I store this list to the RAM so I can use it in my other part of application for comparison ?

+1  A: 

I think the answer on this question might be of use.

Peter Tillemans
@Peter Tillemans gr8 I'll get right into it +1 tnx
London
@Peter Tillemans I updated my question, any help is appreciated
London