FAQ
Is there a way to index data into memory without writing to disk in Lucene ?

This is my current code storing it on disk

writer = new IndexWriter(FSDirectory.open(index_dir), new
IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_40, new
WhitespaceAnalyzer(org.apache.lucene.util.Version.LUCENE_40)));

//store sorted content to contents
Iterator<Map.Entry<String,Cluster>> it = clusters.entrySet().iterator();

while (it.hasNext()) {

...
Document document = new Document();
document.add(new Field("id", id, Field.Store.YES,
Field.Index.ANALYZED));
writer.addDocument(document);
}
writer.optimize();
writer.close();


thanks

Search Discussions

  • Ian Lea at Apr 1, 2011 at 11:11 am
    RAMDirectory. The clue is in the name ...


    --
    Ian.


    On Fri, Apr 1, 2011 at 11:08 AM, Patrick Diviacco
    wrote:
    Is there a way to index data into memory without writing to disk in Lucene ?

    This is my current code storing it on disk

    writer = new IndexWriter(FSDirectory.open(index_dir), new
    IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_40, new
    WhitespaceAnalyzer(org.apache.lucene.util.Version.LUCENE_40)));

    //store sorted content to contents
    Iterator<Map.Entry<String,Cluster>> it = clusters.entrySet().iterator();

    while (it.hasNext()) {

    ...
    Document document  = new Document();
    document.add(new Field("id", id, Field.Store.YES,
    Field.Index.ANALYZED));
    writer.addDocument(document);
    }
    writer.optimize();
    writer.close();


    thanks
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Jm at Apr 1, 2011 at 11:34 am
    or maybe MemoryIndex (in contrib) is more suited to what he wants
    On Fri, Apr 1, 2011 at 1:10 PM, Ian Lea wrote:

    RAMDirectory. The clue is in the name ...


    --
    Ian.


    On Fri, Apr 1, 2011 at 11:08 AM, Patrick Diviacco
    wrote:
    Is there a way to index data into memory without writing to disk in Lucene ?
    This is my current code storing it on disk

    writer = new IndexWriter(FSDirectory.open(index_dir), new
    IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_40, new
    WhitespaceAnalyzer(org.apache.lucene.util.Version.LUCENE_40)));

    //store sorted content to contents
    Iterator<Map.Entry<String,Cluster>> it = clusters.entrySet().iterator();

    while (it.hasNext()) {

    ...
    Document document = new Document();
    document.add(new Field("id", id, Field.Store.YES,
    Field.Index.ANALYZED));
    writer.addDocument(document);
    }
    writer.optimize();
    writer.close();


    thanks
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Patrick Diviacco at Apr 4, 2011 at 11:10 am
    ok Thanks,

    When I use IndexWriter, I call addDocument method to add a new instance to
    the index.

    addDocument takes
    Document doc, Analyzer analyzer

    In MemoryIndex, I have addField which wants:
    String fieldName, String text, Analyzer analyzer

    Not sure how should I pass the doc, should I get the fields and pass each
    field instead? And how do I group them as unique document ? It is not clear
    how it works.

    thanks
    On 1 April 2011 13:33, jm wrote:

    or maybe MemoryIndex (in contrib) is more suited to what he wants
    On Fri, Apr 1, 2011 at 1:10 PM, Ian Lea wrote:

    RAMDirectory. The clue is in the name ...


    --
    Ian.


    On Fri, Apr 1, 2011 at 11:08 AM, Patrick Diviacco
    wrote:
    Is there a way to index data into memory without writing to disk in Lucene ?
    This is my current code storing it on disk

    writer = new IndexWriter(FSDirectory.open(index_dir), new
    IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_40, new
    WhitespaceAnalyzer(org.apache.lucene.util.Version.LUCENE_40)));

    //store sorted content to contents
    Iterator<Map.Entry<String,Cluster>> it =
    clusters.entrySet().iterator();
    while (it.hasNext()) {

    ...
    Document document = new Document();
    document.add(new Field("id", id, Field.Store.YES,
    Field.Index.ANALYZED));
    writer.addDocument(document);
    }
    writer.optimize();
    writer.close();


    thanks
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Patrick Diviacco at Apr 4, 2011 at 11:24 am
    Ok, I've now seen RAMDirectory class instead and I'm using it together what
    the IndexWriter... it should be ok now thanks
    On 4 April 2011 13:10, Patrick Diviacco wrote:

    ok Thanks,

    When I use IndexWriter, I call addDocument method to add a new instance to
    the index.

    addDocument takes
    Document doc, Analyzer analyzer

    In MemoryIndex, I have addField which wants:
    String fieldName, String text, Analyzer analyzer

    Not sure how should I pass the doc, should I get the fields and pass each
    field instead? And how do I group them as unique document ? It is not clear
    how it works.

    thanks

    On 1 April 2011 13:33, jm wrote:

    or maybe MemoryIndex (in contrib) is more suited to what he wants
    On Fri, Apr 1, 2011 at 1:10 PM, Ian Lea wrote:

    RAMDirectory. The clue is in the name ...


    --
    Ian.


    On Fri, Apr 1, 2011 at 11:08 AM, Patrick Diviacco
    wrote:
    Is there a way to index data into memory without writing to disk in Lucene ?
    This is my current code storing it on disk

    writer = new IndexWriter(FSDirectory.open(index_dir), new
    IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_40, new
    WhitespaceAnalyzer(org.apache.lucene.util.Version.LUCENE_40)));

    //store sorted content to contents
    Iterator<Map.Entry<String,Cluster>> it =
    clusters.entrySet().iterator();
    while (it.hasNext()) {

    ...
    Document document = new Document();
    document.add(new Field("id", id, Field.Store.YES,
    Field.Index.ANALYZED));
    writer.addDocument(document);
    }
    writer.optimize();
    writer.close();


    thanks
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedApr 1, '11 at 10:10a
activeApr 4, '11 at 11:24a
posts5
users3
websitelucene.apache.org

3 users in discussion

Patrick Diviacco: 3 posts Ian Lea: 1 post Jm: 1 post

People

Translate

site design / logo © 2022 Grokbase