Class PersonalizedDocFactory


  • public class PersonalizedDocFactory
    extends java.lang.Object
    This class handles the creation of Document object to ensure that there is no conflict in field name and that all the hashcoding behaves as intended.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addField​(org.apache.lucene.index.IndexableField... fields)  
      boolean checkReservedFieldName​(java.lang.String fieldname)  
      void create​(java.lang.Object ID, double[] features)  
      void create​(java.lang.Object ID, org.apache.lucene.index.IndexableField... fields)  
      org.apache.lucene.document.Document getDoc()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public void create​(java.lang.Object ID,
                           double[] features)
                    throws java.lang.Exception
        Parameters:
        ID - unique ID of the document.
        features - the latent feature vector to index.
        Throws:
        DocNotClearedException - this exception is triggered when a call to create(Object, double[]) is not paired with a call to getDoc(). Only use this function to construct a Document containing latent vector. To add additional fields to the Document, use addField(IndexableField...). Call getDoc() to pass the Document to IndexWriter or before creating a new Document.
        java.lang.Exception
      • create

        public void create​(java.lang.Object ID,
                           org.apache.lucene.index.IndexableField... fields)
                    throws SameNameException,
                           DocNotClearedException
        Parameters:
        ID - unique ID of the document
        fields - the custom fields
        Throws:
        SameNameException - this is triggered when one of your custom field has name identical to Cerebro reserved word. See more detail at IndexConst.
        DocNotClearedException - this exception is triggered when a call to create(Object, double[]) is not paired with a call to getDoc(). Call this function to construct a generic text-only Document. Should you need to add latent vector later call getDoc and start anew with the other create method.
      • addField

        public void addField​(org.apache.lucene.index.IndexableField... fields)
                      throws SameNameException
        Parameters:
        fields -
        Throws:
        SameNameException - this is triggered when one of your custom field has name identical to Cerebro reserved word. See more detail at IndexConst. After calling create(Object, double[]) to create a document with latent vector if you still want add more custom fields to a Document then use this function.
      • checkReservedFieldName

        public boolean checkReservedFieldName​(java.lang.String fieldname)
        Parameters:
        fieldname -
        Returns:
        true if the fieldname is the similar to one of the reserved words.