Document.Builder (Google App Engine API for Java)

com.google.appengine.api.search

Class Document.Builder

  • java.lang.Object
    • com.google.appengine.api.search.Document.Builder
  • Direct Known Subclasses:
    ScoredDocument.Builder
    Enclosing class:
    Document


    public static class Document.Builder
    extends java.lang.Object
    A builder of documents. This is not thread-safe.
    • Method Detail

      • setId

        public Document.Builder setId(java.lang.String documentId)
        Set the document id to a unique valid value. A valid document id must be a printable ASCII string of between 1 and DocumentChecker#MAXIMUM_DOCUMENT_ID_LENGTH characters, and also not start with '!' which is reserved. If no document id is provided, then the search service will provide one when the document is indexed.
        Parameters:
        documentId - the unique id for the document to be built
        Returns:
        this builder
        Throws:
        java.lang.IllegalArgumentException - if documentId is not valid
      • addField

        public Document.Builder addField(Field.Builder builder)
        Adds the field builder to the document builder. Allows multiple fields with the same name.
        Parameters:
        builder - the builder of the field to add
        Returns:
        this document builder
      • addField

        public Document.Builder addField(Field field)
        Adds the field to the builder. Allows multiple fields with the same name, except that documents may only have one date and one number field for a name.
        Parameters:
        field - the field to add
        Returns:
        this builder
        Throws:
        java.lang.IllegalArgumentException - if the field is invalid
      • addFacet

        public Document.Builder addFacet(Facet facet)
        Adds a Facet to this builder.
        Parameters:
        facet - the facet to add
        Returns:
        this builder
      • setLocale

        public Document.Builder setLocale(java.util.Locale locale)
        Sets the Locale the document is written in.
        Parameters:
        locale - the Locale the document is written in
        Returns:
        this document builder
      • setRank

        public Document.Builder setRank(int rank)
        Sets the rank of this document, which determines the order of documents returned by search, if no sorting or scoring is given. If it is not specified, then the number of seconds since 2011/1/1 will be used.
        Parameters:
        rank - the rank of this document
        Returns:
        this builder
      • build

        public Document build()
        Builds a valid document. The builder must have set a valid document id, and have a non-empty set of valid fields.
        Returns:
        the document built by this builder
        Throws:
        java.lang.IllegalArgumentException - if the document built is not valid

Send feedback about...