public void TestPostDocument()
        {
            var client = new LuceneClient <SearchDocument>(IndexPath);

            var srchDoc = new SearchDocument()
            {
                id      = "testid2",
                title   = "test title 2",
                summary = "test summary 2",
                url     = "test url 2",
            };

            client.Post(srchDoc);
            client.PostCommit();
        }
        public void TestSearch()
        {
            var client = new LuceneClient(IndexPath);

            var srchRequest = new SearchRequest()
            {
                QueryText = "test",
            };

            var resp = client.Search(srchRequest);

            if (resp.Results.Any())
            {
                var title = resp.Results.First().title;
            }
        }
        public void TestSearch2()
        {
            var client = new LuceneClient(@"C:\iisweb\asrm\ASRM\App_Data\Index\Main");

            client.SearchDefaultField = "EPISERVER_SEARCH_TITLE";

            var srchRequest = new SearchRequest()
            {
                QueryText = "*:*",
            };

            srchRequest.QueryOptions.Add(new FilterQuery("EPISERVER_SEARCH_TYPE", FilterQuery.ConditionalTypes.Contains, "ASRM.Models.Pages.BasePageData"));

            var resp = client.Search(srchRequest);

            if (resp.Results.Any())
            {
                var row = resp.Results.First();

                var title = row.EPISERVER_SEARCH_TITLE;
            }
        }
        static async Task Main(string[] args)
        {
            var client = new ContentClient(HttpClient);
            var token  = await HttpClient.GetToken("sample_console_client", "developmentsecret", $"{client.BaseUrl}/connect/token");

            HttpClient.DefaultRequestHeaders.Clear();
            HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);

            var fooTextItemDto = (await client.Api_GetAsync("4qnhdhv3z54xk4fg4tdfke76c9")) as FooTextItemDto;

            Console.WriteLine("Reading from Api: " + fooTextItemDto.FooText.FooField.Text);

            fooTextItemDto.FooText.FooField.Text = "Foo field value - edited by api - " + Guid.NewGuid().ToString("n");

            fooTextItemDto = (await client.Api_PostAsync(false, fooTextItemDto)) as FooTextItemDto;

            Console.WriteLine("Written and read back from Api: " + fooTextItemDto.FooText.FooField.Text);

            Console.WriteLine(JsonConvert.SerializeObject(fooTextItemDto, Formatting.Indented));

            var queriesClient = new QueriesClient(HttpClient);

            var recentBlogPostsQuery = await queriesClient.Api_Query_PostAsync("RecentBlogPosts", String.Empty);

            foreach (var item in recentBlogPostsQuery.OfType <BlogPostItemDto>())
            {
                Console.WriteLine(item.DisplayText);
            }

            var aliasQuery = await queriesClient.Api_Query_GetAsync("AliasQuery", "{ alias:'categories' }");

            foreach (var item in aliasQuery)
            {
                Console.WriteLine("Sql query for aliases: " + item.DisplayText);
                Console.WriteLine(JsonConvert.SerializeObject(item, Formatting.Indented));
            }

            var luceneClient = new LuceneClient(HttpClient);

            // This style of lucene query will always return content items.
            var luceneContentQuery = await luceneClient.Api_Content_PostAsync("Search", LuceneQuery, String.Empty);

            foreach (var item in luceneContentQuery.Items.OfType <BlogPostItemDto>())
            {
                Console.WriteLine("Lucene query for blogposts: " + item.DisplayText);
            }

            // This style of query can also return any kind of document that is indexed with lucene.
            var luceneDocumentQuery = await luceneClient.Api_Documents_GetAsync("Search", LuceneQuery, null);

            foreach (var item in luceneDocumentQuery)
            {
                Console.WriteLine("Lucene document query: " + item.AdditionalProperties["Content.ContentItem.DisplayText"]);
            }

            var fooClient = new FooClient(HttpClient);
            var fooQuery  = await fooClient.Foo_GetAllAsync();

            foreach (var item in fooQuery)
            {
                Console.WriteLine("Foo : " + item.Text);
            }
        }