You are here: Symbol Reference > dtSearch.Engine Namespace > Classes > SearchResults Class > SearchResults Methods > UrlEncodeItemWithIndexId Method
Close
dtSearch .NET Standard API 2024.02
SearchResults.UrlEncodeItemWithIndexId Method

Creates a url-encoded string describing the currently-selected item in search results.

public string UrlEncodeItemWithIndexId( int iItem, string indexId, int maxLen = 2048, bool asSearch = true, SearchFlags additionalSearchFlags = 0 );

UrlEncodeWithIndexId can be used to create HREFs to use in HTML search results. When the user clicks the link, the URL-encoded item will be sent as part of the Query String. A server-based application that receives the URL-encoded item can then use UrlDecodeItem to convert the data in the HREF back into a SearchResults object. This eliminates the need to keep the SearchResults object in memory between requests, making stateless operation possible on web servers. 

Encoding an item as a search makes more information available after the search to support features such as multi-color hit highlighting. It also provides a way to URL-encode an item with too many hits to store in a URL. 

The indexId parameter provides a way to encode the index location in the URL without exposing the actual location of the index folder. The provided indexId will be stored in the URL as a value named ixid (i.e., "...&ixid=123;&..."). The calling application should extract this ixid value, decode it to the correct path, and then use UrlDecodeItemWithIndex to decode the item with the index path. 

The additionalSearchFlags parameter provides a way to modify the SearchFlags used to rebuild the SearchResults object. For example, to support multicolor hit highlighting, the flags dtsSearchWantHitsByWordOrdinals, dtsSearchWantHitsArray, and dtsSearchWantHitsByWord must be used for the search. 

The maxLen parameter is used to limit the number of hit offsets written to the generated URL. If asSearch is true, the generated URL will not include any hit offsets and maxLen is ignored.

Copyright (c) 1998-2023 dtSearch Corp. All rights reserved.