Class IndexingPolicy


  • public final class IndexingPolicy
    extends JsonSerializable
    Represents the indexing policy configuration for a collection in the Azure Cosmos DB database service.
    • Constructor Detail

      • IndexingPolicy

        public IndexingPolicy()
        Constructor.
      • IndexingPolicy

        public IndexingPolicy​(Index[] defaultIndexOverrides)
        Initializes a new instance of the IndexingPolicy class with the specified set of indexes as default index specifications for the root path.

        The following example shows how to override the default indexingPolicy for root path:

         
         HashIndex hashIndexOverride = Index.HASH(DataType.STRING, 5);
         RangeIndex rangeIndexOverride = Index.RANGE(DataType.NUMBER, 2);
         SpatialIndex spatialIndexOverride = Index.SPATIAL(DataType.POINT);
        
         IndexingPolicy indexingPolicy = new IndexingPolicy(hashIndexOverride, rangeIndexOverride, spatialIndexOverride);
         
         

        If you would like to just override the indexingPolicy for Numbers you can specify just that:

         
         RangeIndex rangeIndexOverride = Index.RANGE(DataType.NUMBER, 2);
        
         IndexingPolicy indexingPolicy = new IndexingPolicy(rangeIndexOverride);
         
         
        Parameters:
        defaultIndexOverrides - comma separated set of indexes that serve as default index specifications for the root path.
    • Method Detail

      • automatic

        public Boolean automatic()
        Gets whether automatic indexing is enabled for a collection.

        In automatic indexing, documents can be explicitly excluded from indexing using RequestOptions. In manual indexing, documents can be explicitly included.

        Returns:
        the automatic
      • automatic

        public IndexingPolicy automatic​(boolean automatic)
        Sets whether automatic indexing is enabled for a collection.

        In automatic indexing, documents can be explicitly excluded from indexing using RequestOptions. In manual indexing, documents can be explicitly included.

        Parameters:
        automatic - the automatic
        Returns:
        the Indexing Policy.
      • indexingMode

        public IndexingMode indexingMode()
        Gets the indexing mode (consistent or lazy).
        Returns:
        the indexing mode.
      • indexingMode

        public IndexingPolicy indexingMode​(IndexingMode indexingMode)
        Sets the indexing mode (consistent or lazy).
        Parameters:
        indexingMode - the indexing mode.
        Returns:
        the Indexing Policy.
      • includedPaths

        public List<IncludedPath> includedPaths()
        Gets the paths that are chosen to be indexed by the user.
        Returns:
        the included paths.
      • setIncludedPaths

        public void setIncludedPaths​(List<IncludedPath> includedPaths)
      • excludedPaths

        public List<ExcludedPath> excludedPaths()
        Gets the paths that are not indexed.
        Returns:
        the excluded paths.
      • compositeIndexes

        public List<List<CompositePath>> compositeIndexes()
        Gets the composite indexes for additional indexes.
        Returns:
        the composite indexes.
      • compositeIndexes

        public IndexingPolicy compositeIndexes​(List<List<CompositePath>> compositeIndexes)
        Sets the composite indexes for additional indexes.
        Parameters:
        compositeIndexes - the composite indexes.
        Returns:
        the Indexing Policy.
      • spatialIndexes

        public List<SpatialSpec> spatialIndexes()
        Sets the spatial indexes for additional indexes.
        Returns:
        the spatial indexes.
      • spatialIndexes

        public IndexingPolicy spatialIndexes​(List<SpatialSpec> spatialIndexes)
        Sets the spatial indexes for additional indexes.
        Parameters:
        spatialIndexes - the spatial indexes.
        Returns:
        the Indexing Policy.