org.springframework.data.mongodb.core.query

Class Collation



  • public class Collation
    extends Object
    Central abstraction for MongoDB collation support.
    Allows fluent creation of a collation Document that can be used for creating collections & indexes as well as querying data.

    NOTE: Please keep in mind that queries will only make use of an index with collation settings if the query itself specifies the same collation.

    Since:
    2.0
    Author:
    Christoph Strobl, Mark Paluch, Jens Schauder
    See Also:
    MongoDB Reference - Collation
    • Method Detail

      • simple

        public static Collation simple()
        Create a Collation using simple binary comparison.
        Returns:
        a Collation for simple binary comparison.
      • of

        public static Collation of(String language)
        Create new Collation with locale set to the given ICU language.
        Parameters:
        language - must not be null.
        Returns:
      • strength

        public Collation strength(int strength)
        Set the level of comparison to perform.
        Parameters:
        strength -
        Returns:
        new Collation.
      • caseLevel

        public Collation caseLevel(boolean caseLevel)
        Set whether to include caseLevel comparison.
        Parameters:
        caseLevel -
        Returns:
        new Collation.
      • caseFirst

        public Collation caseFirst(String caseFirst)
        Set the flag that determines sort order of case differences during tertiary level comparisons.
        Parameters:
        caseFirst - must not be null.
        Returns:
      • caseFirst

        public Collation caseFirst(Collation.CaseFirst sort)
        Set the flag that determines sort order of case differences during tertiary level comparisons.
        Parameters:
        caseFirst - must not be null.
        Returns:
      • numericOrderingEnabled

        public Collation numericOrderingEnabled()
        Treat numeric strings as numbers for comparison.
        Returns:
        new Collation.
      • numericOrderingDisabled

        public Collation numericOrderingDisabled()
        Treat numeric strings as string for comparison.
        Returns:
        new Collation.
      • numericOrdering

        public Collation numericOrdering(boolean flag)
        Set the flag that determines whether to compare numeric strings as numbers or as strings.
        Returns:
        new Collation.
      • alternate

        public Collation alternate(String alternate)
        Set the Field that determines whether collation should consider whitespace and punctuation as base characters for purposes of comparison.
        Parameters:
        alternate - must not be null.
        Returns:
        new Collation.
      • alternate

        public Collation alternate(Collation.Alternate alternate)
        Set the Field that determines whether collation should consider whitespace and punctuation as base characters for purposes of comparison.
        Parameters:
        alternate - must not be null.
        Returns:
        new Collation.
      • backwardDiacriticSort

        public Collation backwardDiacriticSort()
        Sort string with diacritics sort from back of the string.
        Returns:
        new Collation.
      • forwardDiacriticSort

        public Collation forwardDiacriticSort()
        Do not sort string with diacritics sort from back of the string.
        Returns:
        new Collation.
      • backwards

        public Collation backwards(boolean backwards)
        Set the flag that determines whether strings with diacritics sort from back of the string.
        Parameters:
        backwards - must not be null.
        Returns:
        new Collation.
      • normalizationEnabled

        public Collation normalizationEnabled()
        Enable text normalization.
        Returns:
        new Collation.
      • normalizationDisabled

        public Collation normalizationDisabled()
        Disable text normalization.
        Returns:
        new Collation.
      • normalization

        public Collation normalization(boolean normalization)
        Set the flag that determines whether to check if text require normalization and to perform normalization.
        Parameters:
        normalization - must not be null.
        Returns:
        new Collation.
      • maxVariable

        public Collation maxVariable(String maxVariable)
        Set the field that determines up to which characters are considered ignorable when alternate is shifted.
        Parameters:
        maxVariable - must not be null.
        Returns:
        new Collation.
      • toDocument

        public org.bson.Document toDocument()
        Get the Document representation of the Collation.
        Returns:
      • toMongoCollation

        public com.mongodb.client.model.Collation toMongoCollation()
        Get the Collation representation of the Collation.
        Returns: