Class LuceneBuilder<C>

java.lang.Object
es.uam.eps.ir.relison.content.index.AbstractIndexBuilder<C>
es.uam.eps.ir.relison.content.index.lucene.LuceneBuilder<C>
Type Parameters:
C - Type of the contents.
All Implemented Interfaces:
IndexBuilder<C>
Direct Known Subclasses:
LuceneForwardIndexBuilder, LucenePositionalIndexBuilder

public class LuceneBuilder<C>
extends AbstractIndexBuilder<C>
Lucene implementation of an Index Builder
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private org.apache.lucene.index.IndexWriter builder
    Index writer.
    private java.lang.String indexFolder
    Folder in which to store the index
    private it.unimi.dsi.fastutil.ints.Int2ObjectMap<C> map
    Map storing the relation between docids and contents.
    protected static org.apache.lucene.document.FieldType type
    Custom type for storing each content.
  • Constructor Summary

    Constructors 
    Constructor Description
    LuceneBuilder()
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    void close​(java.lang.String indexPath)
    Closes the builder.
    Index<C> getCoreIndex()
    Obtains the generated index.
    int indexText​(java.lang.String text, C content)
    Writes the contents of a user in the index.
    void init​(java.lang.String indexPath)
    Initializes the builder.

    Methods inherited from class es.uam.eps.ir.relison.content.index.AbstractIndexBuilder

    clear, saveContentMap

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • type

      protected static org.apache.lucene.document.FieldType type
      Custom type for storing each content.
    • builder

      private org.apache.lucene.index.IndexWriter builder
      Index writer.
    • indexFolder

      private java.lang.String indexFolder
      Folder in which to store the index
    • map

      private it.unimi.dsi.fastutil.ints.Int2ObjectMap<C> map
      Map storing the relation between docids and contents.
  • Constructor Details

  • Method Details

    • init

      public void init​(java.lang.String indexPath) throws java.io.IOException
      Description copied from interface: IndexBuilder
      Initializes the builder.
      Parameters:
      indexPath - path containing the index.
      Throws:
      java.io.IOException - if something fails while initializing the index.
    • close

      public void close​(java.lang.String indexPath) throws java.io.IOException
      Description copied from interface: IndexBuilder
      Closes the builder.
      Parameters:
      indexPath - path containing the index.
      Throws:
      java.io.IOException - if something fails while closing the index.
    • indexText

      public int indexText​(java.lang.String text, C content) throws java.io.IOException
      Description copied from interface: IndexBuilder
      Writes the contents of a user in the index.
      Parameters:
      text - the published content.
      content - the user.
      Returns:
      the identifier of the new document.
      Throws:
      java.io.IOException - if something fails while writing the contents.
    • getCoreIndex

      public Index<C> getCoreIndex() throws java.io.IOException
      Description copied from class: AbstractIndexBuilder
      Obtains the generated index.
      Specified by:
      getCoreIndex in class AbstractIndexBuilder<C>
      Returns:
      the generated index.
      Throws:
      java.io.IOException - if something fails while creating such index.