当前位置: 首页>>代码示例>>C#>>正文


C# Search.Execute方法代码示例

本文整理汇总了C#中Search.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Search.Execute方法的具体用法?C# Search.Execute怎么用?C# Search.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Search的用法示例。


在下文中一共展示了Search.Execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Search

        public ActionResult Search(string queryText, int? page, string loggingId, string filterQueries, bool? hideSuggestions)
        {
            if (!page.HasValue || page < 1) page = 1;

            // We might have a leading ; from our concatenation
            if (filterQueries != null && filterQueries.StartsWith(";")) filterQueries = filterQueries.Substring(1);
            var fqCollection = new FilterQueryCollection(filterQueries);
            ViewBag.FilterQueryCollection = fqCollection;
            ViewBag.Query = queryText;
            ViewBag.Page = page.Value;
            ViewBag.HideSuggestions = hideSuggestions.HasValue && hideSuggestions.Value;

            var search = new Search<SearchResult>(new Settings("www.crownpeak.com"));
            QueryOptions options = new QueryOptions()
            {
                Highlighting = true,
                Start = (page.Value - 1) * ROWS,
                Rows = ROWS,
                SpellCheck = true,
                FacetFields = new[] { "url", "title" },
                FilterQueries = new FilterQueryCollection(filterQueries),
                LoggingId = loggingId,
                // Language = "en" });
            };
            var results = search.Execute(queryText, options);

            ViewBag.Pager = null;
            ViewBag.LoggingId = "";
            if (results.CrownPeak != null && results.CrownPeak.Logging != null)
            {
                ViewBag.LoggingId = results.CrownPeak.Logging.Id;
            }
            if (results.TotalCount > ROWS)
            {
                // Make a simple pager
                ViewBag.Pager = Enumerable.Range(1, (int)Math.Ceiling((double)results.TotalCount / ROWS));
            }

            return View(results);
        }
开发者ID:Crownpeak,项目名称:Search-Results-Examples,代码行数:40,代码来源:SearchController.cs

示例2: InvalidCollectionReturnsError

 public void InvalidCollectionReturnsError()
 {
     //try
     //{
     //	ClearContainer();
     //	var container = Startup.Container;
     //	container.Register<IEndPointConfiguration>(c => new TestEndPointConfiguration());
     //	ServiceLocator.SetLocatorProvider(() => container);
     //}
     //catch (Exception)
     //{
     //	// Ignore
     //}
     try
     {
         var s = new Search<TestDocument>(new Settings("a-collection-that-does-not-exist"));
         var results = s.Execute("crownpeak");
         Assert.IsTrue(results.Count == 10, "Expected 10 results, got " + results.Count);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         // Restore the state
         SetupSearch();
     }
 }
开发者ID:Crownpeak,项目名称:Search-Results-Examples,代码行数:29,代码来源:GenericSearchTests.cs

示例3: TimingOutReturnsTimeoutError

 public void TimingOutReturnsTimeoutError()
 {
     try
     {
         ClearContainer();
         var container = Startup.Container;
         container.Register<IEndPointConfiguration>(c => new TimeoutTestEndPointConfiguration());
         ServiceLocator.SetLocatorProvider(() => container);
     }
     catch (Exception)
     {
         // Ignore
     }
     try
     {
         var s = new Search<TestDocument>(new Settings("www.crownpeak.com", _endpoint, 1));
         var results = s.Execute("crownpeak");
         Assert.IsTrue(results.Count == 10, "Expected 10 results, got " + results.Count);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         // Restore the state
         SetupSearch();
     }
 }
开发者ID:Crownpeak,项目名称:Search-Results-Examples,代码行数:29,代码来源:GenericSearchTests.cs

示例4: RestrictedCollectionWorksWithCertificate

 public void RestrictedCollectionWorksWithCertificate()
 {
     var Search2 = new Search<TestDocument>(new Settings("authoring-hss.cp-access.com", "https://searchg2-restricted.crownpeak.net/", CertificateCreator.LoadCertificate("E63D2DCEB03E981968F373F5C419E043D9394AF9")));
     var results = Search2.Execute("*:*");
     Assert.AreEqual(results.TotalCount, 13, "Expected 13 results, found " + results.TotalCount);
 }
开发者ID:Crownpeak,项目名称:Search-Results-Examples,代码行数:6,代码来源:GenericSearchTests.cs

示例5: RestrictedCollectionFailsWithoutCertificate

 public void RestrictedCollectionFailsWithoutCertificate()
 {
     var Search2 = new Search<TestDocument>(new Settings("authoring-hss.cp-access.com", "https://searchg2-restricted.crownpeak.net/", null));
     var results = Search2.Execute("*:*");
     Assert.AreEqual(results.TotalCount, 0, "Expected 0 results, found " + results.TotalCount);
 }
开发者ID:Crownpeak,项目名称:Search-Results-Examples,代码行数:6,代码来源:GenericSearchTests.cs


注:本文中的Search.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。