The MDEX Engine returns word interpretation match information in ESearchReport
objects.
This word interpretation information is useful for highlighting or informing users about query expansion.
The Java ESearchReport.getWordInterps()
method and the .NET ESearchReport.WordInterps
property return the set of word interpretations used in the current text search. Each word interpretation is a key/value pair corresponding to the original search term and its interpretation by the MDEX Engine.
In this thesaurus example, assume that you have added the following one-way thesaurus entry:
cab > cabernet
If a search for the term cab finds a match for cabernet, a single word interpretation will be returned with this key/value pair:
Key="cab" Value="cabernet"
When there are multiple substitutions for a given word or phrase, they are comma-separated; for example:
Key="cell phone" Value="mobile phone, wireless phone"
In this Automatic Phrasing example, a search for the terms Napa Valley are automatically phrased to "Napa Valley". A key/value word interpretation is returned with the original search terms as the key and the phrased terms in double quotes as the value.
Key=Napa Valley Value="Napa Valley"
The following code snippets show how to retrieve word interpretation match information.
Example 100. Java example
// 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 searchReport = (ESearchReport)recSrchRpts.get(searchKey); // Get the PropertyMap of word interpretations PropertyMap wordMap = searchReport.getWordInterps(); // Get property iterator Iterator props = wordMap.entrySet().iterator(); // Loop over properties while (props.hasNext()) { // Get individual property Property prop = (Property)props.next(); String propKey = (String)prop.getKey(); String propVal = (String)prop.getValue(); // Display word interpretation information %><tr> <td>Original term: <%= propKey %></td> <td>Interpreted as: <%= propVal %></td> </tr><% } } } }
Example 101. .NET example
// 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 PropertyMap of word interperations PropertyMap wordMap = searchReport.WordInterps; // Get property iterator System.Collections.IList props = wordMap.EntrySet; // Loop over properties for (int j =0; j < props.Count; j++) { // Get individual property Property prop = (Property)props[j]; String propKey = prop.Key.ToString(); String propVal = prop.Value.ToString(); // Display word interpretation information %><tr> <td>Original term: <%= propKey %></td> <td>Interpreted as: <%= propVal %></td> </tr><% } } }