Ejemplo n.º 1
0
        /// <summary>
        /// Create a collection with the required indexing policies for Order By against specific properties.
        /// </summary>
        /// <param name="database">The database to create the collection in.</param>
        /// <returns>The created collection.</returns>
        private async Task <DocumentCollection> CreateCollectionForOrderBySinglePath(Database database)
        {
            IndexingPolicy orderByPolicy = new IndexingPolicy();

            // Index the createdAt property for Order By
            orderByPolicy.IncludedPaths.Add(new IndexingPath {
                Path = "/\"createdAt\"/?", IndexType = IndexType.Range, NumericPrecision = -1
            });

            // Index all numeric paths under "user" for Order By
            orderByPolicy.IncludedPaths.Add(new IndexingPath {
                Path = "/\"user\"/*", IndexType = IndexType.Range, NumericPrecision = -1
            });

            // Use the default (Hash) for everything else.
            orderByPolicy.IncludedPaths.Add(new IndexingPath {
                Path = "/"
            });

            // Here we create as a S1.
            DocumentCollection collection = await DocumentClientHelper.CreateNewCollection(
                this.client,
                database,
                "tweetsCollectionSinglePath",
                new DocumentCollectionInfo { IndexingPolicy = orderByPolicy, OfferType = "S1" });

            return(collection);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a collection with the required indexing policies for Order By against any numeric or string property.
        /// Note that the default policy allows Order By only against numbers.
        /// </summary>
        /// <param name="database">The database to create the collection in.</param>
        /// <returns>The created collection.</returns>
        private async Task <DocumentCollection> CreateCollectionForOrderBy(Database database)
        {
            IndexingPolicy orderByPolicy = new IndexingPolicy();

            orderByPolicy.IncludedPaths.Add(new IncludedPath
            {
                Path    = "/*",
                Indexes = new System.Collections.ObjectModel.Collection <Index>()
                {
                    new RangeIndex(DataType.String)
                    {
                        Precision = -1
                    },
                    new RangeIndex(DataType.Number)
                    {
                        Precision = -1
                    }
                }
            });

            // Here we create as a S1.
            DocumentCollection collection = await DocumentClientHelper.CreateNewCollection(
                this.client,
                database,
                "tweetsCollection",
                new DocumentCollectionSpec { IndexingPolicy = orderByPolicy, OfferType = "S1" });

            return(collection);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a collection with the required indexing policies for Order By against specific properties.
        /// </summary>
        /// <param name="database">The database to create the collection in.</param>
        /// <returns>The created collection.</returns>
        private async Task <DocumentCollection> CreateCollectionForOrderBySinglePath(Database database)
        {
            IndexingPolicy orderByPolicy = new IndexingPolicy();

            // Index the createdAt property for Order By
            orderByPolicy.IncludedPaths.Add(new IncludedPath
            {
                Path    = "/createdAt/?",
                Indexes = new System.Collections.ObjectModel.Collection <Index>()
                {
                    new RangeIndex(DataType.Number)
                    {
                        Precision = -1
                    }
                }
            });

            // Index all string and numeric paths under "user" for Order By
            orderByPolicy.IncludedPaths.Add(new IncludedPath
            {
                Path    = "/user/*",
                Indexes = new System.Collections.ObjectModel.Collection <Index>()
                {
                    new RangeIndex(DataType.Number)
                    {
                        Precision = -1
                    },
                    new RangeIndex(DataType.String)
                    {
                        Precision = -1
                    },
                }
            });

            // Use the default (Hash) for everything else.
            orderByPolicy.IncludedPaths.Add(new IncludedPath {
                Path = "/*"
            });

            // Here we create as a S1.
            DocumentCollection collection = await DocumentClientHelper.CreateNewCollection(
                this.client,
                database,
                "tweetsCollectionSinglePath",
                new DocumentCollectionSpec { IndexingPolicy = orderByPolicy, OfferType = "S1" });

            return(collection);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a collection with the required indexing policies for Order By against any numeric property.
        /// </summary>
        /// <param name="database">The database to create the collection in.</param>
        /// <returns>The created collection.</returns>
        private async Task <DocumentCollection> CreateCollectionForOrderBy(Database database)
        {
            IndexingPolicy orderByPolicy = new IndexingPolicy();

            orderByPolicy.IncludedPaths.Add(new IndexingPath {
                Path = "/", IndexType = IndexType.Range, NumericPrecision = -1
            });

            // Here we create as a S1.
            DocumentCollection collection = await DocumentClientHelper.CreateNewCollection(
                this.client,
                database,
                "tweetsCollection",
                new DocumentCollectionInfo { IndexingPolicy = orderByPolicy, OfferType = "S1" });

            return(collection);
        }