There are no modifications that are strictly necessary in the Presentation API code to support spelling correction. However, there are API calls that return information about automatic spelling correction and DYM objects.
Spelling corrected results for both dimension search and record search operations are returned as normal search results.
Optionally, applications can display information about automatic spelling corrections or Did You Mean suggestions for dimension or record search operations using the automatically-generated ESearchReport objects returned by the MDEX Engine.
<application>?N=0&Ntk=AllText|Manufacturer&Ntt=cdd|sny&Nty=1
The Java Navigation.getESearchReports() method and the .NET Navigation.ESearchReports property return a list of two ESearchReport objects that provides access to the information listed in the following two tables.
ESearchReport Java method | Returned value |
---|---|
getKey() | AllText |
getTerms() | Cdd |
getSearchMode() | MatchAll |
getMatchedMode() | MatchAll |
getNumMatchingResults() | 122 |
getAutoSuggestions().get(0).getTerms() | Cd |
getDYMSuggestions().get(0).getTerms() | Ccd |
getDYMSuggestions().get(0).getNumMatchingResults() | 6 |
getDYMSuggestions().get(1).getTerms() | Cdp |
getDYMSuggestions().get(1).getNumMatchingResults() | 7 |
getKey() | Manufacturer |
getTerms() | Sny |
getSearchMode() | MatchAll |
getMatchedMode() | MatchAll |
getNumMatchingResults() | 121 |
getAutoSuggestions().get(0).getTerms() | Sony |
ESearchReport .NET property | Returned value |
---|---|
Key | AllText |
Terms | Cdd |
SearchMode | MatchAll |
MatchedMode | MatchAll |
NumMatchingResults | 122 |
AutoSuggestions[(0)].Terms | Cd |
DYMSuggestions[(0)].Terms | Ccd |
DYMSuggestions[(0)].NumMatchingResults | 6 |
DYMSuggestions[(1)].Terms | Cdp |
DYMSuggestions[(1)].NumMatchingResults | 7 |
Key | Manufacturer |
Terms | Sny |
SearchMode | MatchAll |
MatchedMode | MatchAll |
NumMatchingResults | 121 |
AutoSuggestions[(0)].Terms | Sony |
Note that the auto-correct spelling corrections and the explicit Did You Mean suggestions are grouped with related record search operations. (In this case, cd is the spelling correction for cdd and sony is the spelling correction for sny.)
// Get the Map of ESearchReport objects Map recSrchRpts = nav.getESearchReports(); if (recSrchRpts.size() > 0) { // Get the user’s search key String searchKey = request.getParameter("Ntk"); if (searchKey != null) { if (recSrchRpts.containsKey(searchKey)) { // Get the ERecSearchReport for the search key ESearchReport srchRpt = (ESearchReport)recSrchRpts.get(searchKey); // Get the List of auto-correct values List autoCorrectList = srchRpt.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 autocorrect message %>Corrected to <%= autoSug.getTerms() %> } } } }
// Get the Dictionary of ESearchReport objects IDictionary recSrchRpts = nav.ESearchReports; // Get the user’s search key String searchKey = Request.QueryString["Ntk"]; if (searchKey != null) { if (recSrchRpts.Contains(searchKey)) { // Get the first Search Report object IDictionaryEnumerator ide = recSrchRpts.GetEnumerator(); ide.MoveNext(); ESearchReport searchReport = (ESearchReport)ide.Value; // Get the List of auto-correct objects IList autoCorrectList = searchReport.AutoSuggestions; // If the list contains Auto Suggestion objects, // print the value of the first corrected term if (autoCorrectList.Count > 0) { // Get the Auto Suggestion object ESearchAutoSuggestion autoSug = (ESearchAutoSuggestion)autoCorrectList[0]; // Display autocorrect message %>Corrected to <%= autoSug.Terms %> } } }
// Get the Map of ESearchReport objects Map dymRecSrchRpts = nav.getESearchReports(); if (dymRecSrchRpts.size() > 0) { // Get the user's search key String searchKey = request.getParameter("Ntk"); if (searchKey != null) { if (dymRecSrchRpts.containsKey(searchKey)) { // Get the ERecSearchReport for the user's search key ESearchReport searchReport = (ESearchReport) dymRecSrchRpts.get(searchKey); // Get the List of Did You Mean objects List dymList = searchReport.getDYMSuggestions(); // If the list contains Did You Mean objects, provide a // link to search on the first suggested term if (dymList.size() > 0) { // Get the Did You Mean object ESearchDYMSuggestion dymSug = (ESearchDYMSuggestion)dymList.get(0); String sug_val = dymSug.getTerms(); if (sug_val != null){ // Display didyoumean link %>Did You Mean: <%= sug_val %> } } } } }
dd // Get the Dictionary of ESearchReport objects IDictionary dymRecSrchRpts = nav.ESearchReports; // Get the user’s search key String dymSearchKey = Request.QueryString["Ntk"]; if (dymSearchKey != null) { if (dymRecSrchRpts.Contains(dymSearchKey)) { // Get the first Search Report object IDictionaryEnumerator ide = dymRecSrchRpts.GetEnumerator(); ide.MoveNext(); ESearchReport searchReport = (ESearchReport)ide.Value; // Get the List of DYM objects IList dymList = searchReport.DYMSuggestions; // If the list contains DYM objects, print the value // of the first suggested term if (dymList.Count > 0) { // Get the DYM object ESearchDYMSuggestion dymSug = (ESearchDYMSuggestion)dymList[0]; String sug_val = dymSug.Terms; String sug_num = dymSug.NumMatchingResults.ToString(); // Display DYM message if (sug_val != null){ %>Did You Mean: <%= sug_val %> } } } }