コード例 #1
0
        private static void CreateCatalogIndex()
        {
            var definition = new
            {
                Name   = "catalog",
                Fields = new[]
                {
                    new { Name = "productID", Type = "Edm.String", Key = true, Searchable = false, Filterable = false, Sortable = false, Facetable = false, Retrievable = true, Suggestions = false },
                    new { Name = "name", Type = "Edm.String", Key = false, Searchable = true, Filterable = false, Sortable = true, Facetable = false, Retrievable = true, Suggestions = true },
                    new { Name = "productNumber", Type = "Edm.String", Key = false, Searchable = true, Filterable = false, Sortable = false, Facetable = false, Retrievable = true, Suggestions = true },
                    new { Name = "color", Type = "Edm.String", Key = false, Searchable = true, Filterable = true, Sortable = true, Facetable = true, Retrievable = true, Suggestions = false },
                    new { Name = "standardCost", Type = "Edm.Double", Key = false, Searchable = false, Filterable = false, Sortable = false, Facetable = false, Retrievable = true, Suggestions = false },
                    new { Name = "listPrice", Type = "Edm.Double", Key = false, Searchable = false, Filterable = true, Sortable = true, Facetable = true, Retrievable = true, Suggestions = false },
                    new { Name = "size", Type = "Edm.String", Key = false, Searchable = true, Filterable = true, Sortable = true, Facetable = true, Retrievable = true, Suggestions = false },
                    new { Name = "weight", Type = "Edm.Double", Key = false, Searchable = false, Filterable = true, Sortable = false, Facetable = true, Retrievable = true, Suggestions = false },
                    new { Name = "sellStartDate", Type = "Edm.DateTimeOffset", Key = false, Searchable = false, Filterable = true, Sortable = false, Facetable = false, Retrievable = false, Suggestions = false },
                    new { Name = "sellEndDate", Type = "Edm.DateTimeOffset", Key = false, Searchable = false, Filterable = true, Sortable = false, Facetable = false, Retrievable = false, Suggestions = false },
                    new { Name = "discontinuedDate", Type = "Edm.DateTimeOffset", Key = false, Searchable = false, Filterable = true, Sortable = false, Facetable = false, Retrievable = true, Suggestions = false },
                    new { Name = "categoryName", Type = "Edm.String", Key = false, Searchable = true, Filterable = true, Sortable = false, Facetable = true, Retrievable = true, Suggestions = true },
                    new { Name = "modelName", Type = "Edm.String", Key = false, Searchable = true, Filterable = true, Sortable = false, Facetable = true, Retrievable = true, Suggestions = true },
                    new { Name = "description", Type = "Edm.String", Key = false, Searchable = true, Filterable = true, Sortable = false, Facetable = false, Retrievable = true, Suggestions = false }
                }
            };

            Uri    uri  = new Uri(_serviceUri, "/indexes");
            string json = AzureSearchHelper.SerializeJson(definition);
            HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(_httpClient, HttpMethod.Post, uri, json);

            response.EnsureSuccessStatusCode();
        }
コード例 #2
0
    /// <summary>
    /// This function will create the specified index.
    /// </summary>
    /// <returns>string - Results response</returns>
    private string CreateCatalogIndex()
    {
        try
        {
            var definition = new
            {
                Name   = this.AzureSearchServiceIndexName,
                Fields = new[]
                {
                    new { Name = "DocumentID", Type = "Edm.String", Key = true, Searchable = false, Filterable = false, Sortable = false, Facetable = false, Retrievable = true, Suggestions = false },
                    new { Name = "DocumentName", Type = "Edm.String", Key = false, Searchable = true, Filterable = false, Sortable = true, Facetable = false, Retrievable = true, Suggestions = true }
                }
            };

            Uri    uri  = new Uri(_serviceUri, "/indexes");
            string json = AzureSearchHelper.SerializeJson(definition);
            HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(_httpClient, HttpMethod.Post, uri, json);
            response.EnsureSuccessStatusCode();
            return("Index created.");
        }
        catch (Exception ex)
        {
            return("Index not created.<br />" + ex.Message);
        }
    }
コード例 #3
0
        private static void IndexCatalogBatch(List <Dictionary <string, object> > changes)
        {
            var batch = new
            {
                value = changes
            };

            Uri    uri  = new Uri(_serviceUri, "/indexes/catalog/docs/index");
            string json = AzureSearchHelper.SerializeJson(batch);
            HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(_httpClient, HttpMethod.Post, uri, json);

            response.EnsureSuccessStatusCode();
        }