예제 #1
0
 static void HandleItemsIteratorSession(object iterator, List <SearchItem> allItems, SearchProvider provider, SearchContext context, SearchFlags options)
 {
     if (iterator != null && options.HasAny(SearchFlags.Synchronous))
     {
         using (var stackedEnumerator = new SearchEnumerator <SearchItem>(iterator))
         {
             while (stackedEnumerator.MoveNext())
             {
                 if (stackedEnumerator.Current != null)
                 {
                     allItems.Add(stackedEnumerator.Current);
                 }
             }
         }
     }
     else
     {
         var session = context.sessions.GetProviderSession(provider);
         session.Reset(context.sessions.currentSessionContext, iterator, k_MaxFetchTimeMs, k_MaxSessionTimeMs);
         session.Start();
         var sessionEnded = !session.FetchSome(allItems, k_MaxFetchTimeMs);
         if (options.HasAny(SearchFlags.FirstBatchAsync))
         {
             session.SendItems(context.subset != null ? allItems.Intersect(context.subset) : allItems);
             allItems.Clear();
         }
         if (sessionEnded)
         {
             session.Stop();
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Create a search context with a single search provider.
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="searchText"></param>
 /// <returns></returns>
 public static SearchContext CreateContext(SearchProvider provider, string searchText = "")
 {
     return(CreateContext(new[] { provider }, searchText));
 }
예제 #3
0
 /// <summary>
 /// Run a search query in the index.
 /// </summary>
 /// <param name="searchQuery">Search query to look out for. If if matches any of the indexed variations a result will be returned.</param>
 /// <param name="context">The search context on which the query is applied.</param>
 /// <param name="provider">The provider that initiated the search.</param>
 /// <param name="maxScore">Maximum score of any matched Search Result. See <see cref="SearchResult.score"/>.</param>
 /// <param name="patternMatchLimit">Maximum number of matched Search Result that can be returned. See <see cref="SearchResult"/>.</param>
 /// <returns>Returns a collection of Search Result matching the query.</returns>
 public override IEnumerable <SearchResult> Search(string searchQuery, SearchContext context, SearchProvider provider, int maxScore = int.MaxValue, int patternMatchLimit = 2999)
 {
     if (settings.options.disabled)
     {
         return(Enumerable.Empty <SearchResult>());
     }
     return(base.Search(searchQuery, context, provider, maxScore, patternMatchLimit).Take(patternMatchLimit));
 }