Ejemplo n.º 1
0
        // Returns an initialized 'SearchServiceClient' instance for the specified index
        private static ISearchIndexClient InitializeIndex(string indexCodeName)
        {
            // Converts the Xperience index code name to a valid Azure Search index name (if necessary)
            indexCodeName = NamingHelper.GetValidIndexName(indexCodeName);

            SearchIndexInfo     index  = SearchIndexInfoProvider.GetSearchIndexInfo(indexCodeName);
            SearchServiceClient client = new SearchServiceClient(index.IndexSearchServiceName, new SearchCredentials(index.IndexAdminKey));

            return(client.Indexes.GetClient(indexCodeName));
        }
    /// <summary>
    /// Returns initialized <see cref="SearchServiceClient"/> based on index name "sample-dancinggoat-coffee-azure".
    /// </summary>
    private ISearchIndexClient GetSearchClient()
    {
        var indexName = NamingHelper.GetValidIndexName("sample-dancinggoat-coffee-azure");
        var indexInfo = SearchIndexInfoProvider.GetSearchIndexInfo(indexName);

        if (indexInfo == null)
        {
            return(null);
        }

        var serviveClient = new SearchServiceClient(indexInfo.IndexSearchServiceName, new SearchCredentials(indexInfo.IndexAdminKey));

        return(serviveClient.Indexes.GetClient(indexName));
    }