The SearchParameters class encapsulates the mandatory and optional parameters used to specify how to carry out a search.
SearchParameters example:
Examples
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; } } }
Inheritance Hierarchy
Ankiro.SearchServer.Data.Search SearchParameters
Namespace: Ankiro.SearchServer.Data.Search
Assembly: Ankiro.SearchServer.Data (in Ankiro.SearchServer.Data.dll) Version: 1.13.770.19207 (1.13.770.19207)
Syntax
The SearchParameters type exposes the following members.
Constructors
Name | Description | |
---|---|---|
![]() | SearchParameters | Initializes a new instance of the SearchParameters class |
![]() | SearchParameters(Int32, String) | Initializes a new instance of the SearchParameters class |
Methods
Name | Description | |
---|---|---|
![]() | AddFacetParameter(String, Parameter) | |
![]() | AddFacetParameter(String, String ) | |
![]() | AddParameter(String, Parameter) | |
![]() | AddParameter(String, String ) | |
![]() ![]() | DeserializeParameter | |
![]() | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IsValidForLogging | |
![]() ![]() | SerializeParameter | |
![]() ![]() | SerializeParameterToTextWriter | |
![]() | ToString | Returns a String that represents the current Object. (Inherited from Object.) |
Properties
Name | Description | |
---|---|---|
![]() | CacheForPreviewSearch |
If true, the search will be cached for future preview searches. Set to false for non-standard searches. If not set, some heuristics will be applied.
Default value: null
|
![]() | CustomExcludedProperties |
Optional:
If specified, excluded document property property values are excluded from the returned result,
regardless of whether the property is specified as 'return with result' on the index level, or is
included in the 'CustomReturnedProperties' collection.
|
![]() | CustomProcessingParameters |
Optional:
Only parameter names specified in this list can be the target of custom parameter processing.
If the list is null or empty, no restrictions on parameters are applied.
To disable processing completely use the DisableCustomParameterProcessing property.
|
![]() | CustomReturnedProperties |
Optional:
If specified, only document property values in this list are returned for matched documents,
regardless of any 'return with result' setting on the index level. If the collection is null or empty (default case),
'return with result' settings on the index level is used to control whether document property data
are returned in the search result.
|
![]() | DisableAdaptiveRanking |
If true, disables the adaptive ranking algorithm. The adaptive ranking algorithm improves
search quality using the logged searches and clicks.
Disabling this feature may have some performance benefits at the cost of search quality.
|
![]() | DisableCustomParameterProcessing |
Optional: If true, any custom search parameter processing active on the server will be disabled.
This only applies to solutions that use ontology integration or other custom pre-processing of
search parameters.
Default value: false.
|
![]() | EmptySearchStringMatchesAll |
Optional: If true and SearchString is null or empty, all documents are matched by the search. Use this parameter in conjunction with the GroupSummation
construct to retrieve information about the number of documents across distinct property values.
Default value: false
|
![]() | ExtensionData | |
![]() | FacetParameters |
Optional: Facet parameters to use for the search. The Parameters and FacetParameters collections form a logical 'union' of parameters,
which will all be reflected in the final search result. The difference between the two collections is that when FacetParameters is populated,
an extra search is carried out internally by AES which populates SearchResult.PreFacetInfo with the group info and group summation information
that would have been obtained _without_ the specified facet parameters. Please refer to the documentation site for more information. |
![]() | FailOnError |
If true, a FaultException is emitted if an error occurs during search. Otherwise an empty search result is returned. Default behavior: Fail on error.
|
![]() | LogSearch |
If true, the search is logged, otherwise the search is not logged.
Default value: true
|
![]() | LogSearchParameters |
If true, search parameters that have LogParameterValues=true and which are specified in the Parameters collection will be logged for the search.
Default value: false
|
![]() | MaxResults |
Specifies the maximum number of results to retrieve when searching. The number of documents returned may be less than the
number specified, if the search matches fewer than MaxResults-Offset documents.
The maximum allowed value for MaxResults is 1000.
|
![]() | Offset |
Logical offset (zero-based) of the first document to retrieve in the total result set.
The offset parameter is used to control paging, i.e. in order to control whether documents should be returned for the
'first' page of a search result, or for a subsequent page.
|
![]() | Parameters |
Optional: Search profile parameters to use for the search. Parameters are used to control dynamic aspects of a search,
and interacts with the xml definition of a search profile. Please refer to the documentation site for more information. |
![]() | PositionLimiter |
Optional: Limits search results based on a DocumentData.Position match.
Use of this parameters assumes the existence/reference of a search profile criterion targeting the built-in property 'Ankiro.Position'.
|
![]() | RefreshCache |
If true, the search result cache is bypassed for this search making sure the search is re-executed.
|
![]() | RequestedBy |
Optional: Used for logging purposes. RequestedBy should contain the ip adress or similar identifiable information for the user on whose
behalf the search is carried out. This is logged in the database if LogSearch=true.
|
![]() | ReturnDiagnostics |
If true, diagnostics regarding search time will be returned in the search result.
|
![]() | ReturnHotspotInformation |
If true, populates the HotspotInformation field of matched ResultDocument entries, revealing which terms were matched in individual documents.
|
![]() | ReturnLegacySearchResult |
If true, a legacy XML result will be attached to the SearchResult instance returned by the Search.
|
![]() | RoleNames |
Optional: Used to filter the search result based on datasource role access information.
The collection should contain the set of global user or role names that the user has access to.
Examples 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; } } } |
![]() | SearchId |
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.
Examples 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; } } } |
![]() | SearchPaths |
Optional: Used to filter the search result based on datasource path hierarchy information.
Per default, if the SearchPaths collection is null or empty, all data sources associated with searched index(es) are searched.
If at least one entry is contained in the SearchPaths collection, the SearchPaths collection must specify all datasource paths
that should be searched (or NOT search through usage of the Exclude SearchBehavior type of the SearchPath class).
|
![]() | SearchProfileId |
Id of the search profile to use when searching.
|
![]() | SearchString |
Specifies the primary search string to search for. The SearchString parameter is accessed in search profile definitions through the
'search-string' parameter.
|
![]() | SessionId |
Optional: Used for logging purposes. SessionId should contain the session identifier of the user session used to carry out the search.
Maintaining session information for statistical purposes is useful to analyze trends in user behavior.
Examples 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; } } } |
![]() | SpellcheckSearchString |
Optional: If true, the search string is spellchecked and spellcheck suggestions are included in the search. Spellchecking is carried out according
to the specified SearchLanguage, controlling the set of phonetic and language-specific rules used, and the dictionaries spellchecked against.
Default value: false
|
See Also