To display messages for spell-corrected and automatically-phrased queries, your Web application code should be similar to these examples.
Example 86. Java example
// Get the Map of lists of ESearchReport objects
Map recSrchRpts = nav.getESearchReportsComplete();
if (recSrchRpts.size() > 0) {
// Get the user's search key
String searchKey = request.getParameter("Ntk");
if (searchKey != null) {
if (recSrchRpts.containsKey(searchKey)) {
// Get the ERecSearchReports for the search key
List srchRptList = (List)recSrchRpts.get(searchKey);
// for each report, display appropriate info
for (Iterator i = srchRptList.Iterator(); i.hasNext();) {
ESearchReport srchRpt = (ESearchReport)i.next();
// Get the List of auto-correct values
List autoCorrectList = searchReport.getAutoSuggestions();
// If the list contains Auto Suggestion objects,
// print the value of the first corrected term
if (autoCorrectList.size() > 0) {
// Get the Auto Suggestion object
ESearchAutoSuggestion autoSug =
(ESearchAutoSuggestion)autoCorrectList.get(0);
// Display appropriate autocorrect message
if (autoSug.didSuggestionIncludeSpellingCorrection() &&
!autoSug.didSuggestionIncludeAutomaticPhrasing()) {
%>Spelling corrected to <%= autoSug.getTerms() %> <%
}
else if(autoSug.didSuggestionIncludeSpellingCorrection() &&
autoSug.didSuggestionIncludeAutomaticPhrasing()) {
%>Spelling corrected and then phrased
to <%= autoSug.getTerms() %> <%
}
else if(!autoSug.didSuggestionIncludeSpellingCorrection()&&
autoSug.didSuggestionIncludeAutomaticPhrasing()) {
%>Phrased to <%= autoSug.getTerms() %> <%
}
}
}
}
}
}
Example 87. .NET example
// Get the Dictionary of lists of ESearchReport objects
IDictionary recSrchRpts = nav.ESearchReportsComplete;
// Get the user's search key
String searchKey = Request.QueryString["Ntk"];
if (searchKey != null) {
if (recSrchRpts.Contains(searchKey)) {
// Get the list of Search Report objects
IList srchReportList = (IList)recSrchRpts[searchKey];
// for each report, display appropriate info
foreach (object ob in srchReportList) {
ESearchReport searchReport = (ESearchReport)ob;
// Get the List of auto correct objects
IList autoCorrectList = searchReport.AutoSuggestions;
// If the list contains auto correct objects,
// print the value of the first corrected term
if (autoCorrectList.Count > 0) {
// Get the Auto Suggestion object
ESearchAutoSuggestion autoSug =
(ESearchAutoSuggestion)autoCorrectList[0];
// Display appropriate autocorrect message
if (autoSug.GetDidSuggestionIncludeSpellingCorrection() &&
!autoSug.GetDidSuggestionIncludeAutomaticPhrasing()) {
%>Spelling corrected to <%= autoSug %> <%
else if (autoSug.GetDidSuggestionIncludeSpellingCorrection() &&
autoSug.GetDidSuggestionIncludeAutomaticPhrasing()) {
%>Spelling corrected and phrased to
<%= autoSug.getTerms() %> <%
}
else if (!autoSug.GetDidSuggestionIncludeSpellingCorrection()&&
autoSug.GetDidSuggestionIncludeAutomaticPhrasing()) {
%>Phrased to <%= autoSug.getTerms() %> <%
}
}
}
}

