SearchId is used in conjunction with paging to control how statistics are saved. When a user performs a search, reviews the first page of returned
results and then navigates to a subsequent result page, the documents for the subsequent result page is actually obtained by performing a new search
with an updated Offset.
SearchId should be used when performing these subsequent searches, setting the value of SearchId to the SearchId returned in the initial SearchResult.
SearchParameters example:
Namespace: Ankiro.SearchServer.Data.SearchExamples
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ankiro.Suite.Client.SearchSample.SearchService; namespace Ankiro.Suite.Client.SearchSample { public class SearchIdExample { private SearchWebService searchService; public SearchIdExample(SearchWebService service) { searchService = service; SearchProfileId = 1; ResultsPerPage = 10; } public int SearchProfileId { get; set; } public int ResultsPerPage { get; set; } private Guid? _searchId; /// <summary> /// Executes a paged search. Page is assumed to be 1-offset, so that e.g. page=1 retrieves the first 'ResultsPerPage' results. /// </summary> /// <param name="searchString"></param> /// <param name="page"></param> /// <returns></returns> public SearchResult ExecutePagedSearch(string searchString, int page) { if (page < 1) throw new ArgumentException("page"); var result = searchService.Search(new SearchParameters() { SearchProfileId = SearchProfileId, SearchString = searchString, // Calculate the logical offset of the first document to retrieve, taking paging into account. Offset = (page-1) * ResultsPerPage, MaxResults = ResultsPerPage, // Transmit any previously retrieved SearchId to make sure that logging is done correctly. SearchId = _searchId.HasValue ? _searchId.Value : Guid.Empty, // LogSearch is overriden to false if SearchId is not empty LogSearch = true, SessionId = HttpContext.Current.Session.SessionID, RequestedBy = HttpContext.Current.Request.UserHostAddress, }); if (!_searchId.HasValue) _searchId = result.SearchId; return result; } } }
Assembly: Ankiro.SearchServer.Data (in Ankiro.SearchServer.Data.dll) Version: 1.13.770.19207 (1.13.770.19207)
Syntax
Property Value
Type: Nullable GuidSee Also