Class LuceneIndex<C>

java.lang.Object
es.uam.eps.ir.relison.content.index.AbstractIndex<C>
es.uam.eps.ir.relison.content.index.lucene.LuceneIndex<C>
Type Parameters:
C - Type of the contents.
All Implemented Interfaces:
DocumentMap<C>, Index<C>
Direct Known Subclasses:
LuceneForwardIndex, LucenePositionalIndex

public class LuceneIndex<C>
extends AbstractIndex<C>
Lucene implementation of an index.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected org.apache.lucene.index.IndexReader index
    Object for accessing the index.

    Fields inherited from class es.uam.eps.ir.relison.content.index.AbstractIndex

    backward, forward
  • Constructor Summary

    Constructors 
    Constructor Description
    LuceneIndex​(java.lang.String indexFolder, it.unimi.dsi.fastutil.ints.Int2ObjectMap<C> map)
    Auxiliar constructor.
    LuceneIndex​(java.lang.String indexFolder, org.ranksys.formats.parsing.Parser<C> cParser)
    General constructor.
  • Method Summary

    Modifier and Type Method Description
    java.util.Collection<java.lang.String> getAllTerms()
    Obtains the set of all terms in the index dictionary.
    long getDocFreq​(java.lang.String term)
    Obtains the number of documents containing the term.
    PostingsList getPostings​(java.lang.String term)
    Obtains the posting list of a term.
    long getTotalFreq​(java.lang.String term)
    Obtains the total frequency of a term in the collection.
    int numDocs()
    Obtains the number of contents.

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

    getContent, getContentId, loadContents

    Methods inherited from class java.lang.Object

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

    • index

      protected org.apache.lucene.index.IndexReader index
      Object for accessing the index.
  • Constructor Details

    • LuceneIndex

      public LuceneIndex​(java.lang.String indexFolder, org.ranksys.formats.parsing.Parser<C> cParser) throws java.io.IOException
      General constructor.
      Parameters:
      indexFolder - folder in which the index is stored.
      cParser - content parser.
      Throws:
      java.io.IOException - if something fails while initializing the index.
    • LuceneIndex

      public LuceneIndex​(java.lang.String indexFolder, it.unimi.dsi.fastutil.ints.Int2ObjectMap<C> map) throws java.io.IOException
      Auxiliar constructor.
      Parameters:
      indexFolder - folder in which the index is stored.
      map - user to id map.
      Throws:
      java.io.IOException - if something fails while initializing the index.
  • Method Details

    • getAllTerms

      public java.util.Collection<java.lang.String> getAllTerms() throws java.io.IOException
      Description copied from interface: Index
      Obtains the set of all terms in the index dictionary.
      Returns:
      the collection of terms.
      Throws:
      java.io.IOException - if something fails while reading the list of terms.
    • numDocs

      public int numDocs()
      Description copied from interface: DocumentMap
      Obtains the number of contents.
      Returns:
      the number of contents.
    • getDocFreq

      public long getDocFreq​(java.lang.String term) throws java.io.IOException
      Description copied from interface: Index
      Obtains the number of documents containing the term.
      Parameters:
      term - the term to look up.
      Returns:
      the number of documents containing the term.
      Throws:
      java.io.IOException - if something fails while reading the doc frequency.
    • getTotalFreq

      public long getTotalFreq​(java.lang.String term) throws java.io.IOException
      Description copied from interface: Index
      Obtains the total frequency of a term in the collection.
      Parameters:
      term - the term to look up.
      Returns:
      the total frequency of the term in the collection.
      Throws:
      java.io.IOException - if something fails while reading the frequency.
    • getPostings

      public PostingsList getPostings​(java.lang.String term) throws java.io.IOException
      Description copied from interface: Index
      Obtains the posting list of a term.
      Parameters:
      term - the term to look up.
      Returns:
      the posting list of the term.
      Throws:
      java.io.IOException - if something fails while reading the posting list.