You can retrieve automatic spelling corrections and suggested corrections (Did You Mean) information in a query using the SearchAdjustmentConfig type in your Conversation Web Service request.
If spelling is enabled in the data domain and you want the Conversation Web Service response to contain supplemental information about spelling corrections and spelling suggestions (DYM), a SearchAdjustmentConfig type is required. If it is included, spelling corrections and/or DYM suggestions are returned as part of the response.
It is important to realize that if spelling is enabled, spelling auto-correction occurs even if the SearchAdjustmentConfig type is not included. However, while spelling correction takes place, the spelling corrections and DYM suggestions are not returned in the response.
<SearchAdjustmentConfig Id="?"> <StateName>?</StateName> </SearchAdjustmentConfig>where the attributes mean:
Attribute | Meaning |
---|---|
Id | A required attribute that provides an arbitrary identifier for this configuration. |
StateName | Specifies an existing named state in the
request, using these rules:
|
<Request xmlns="http://www.endeca.com/MDEX/conversation/3/0"> <State> <TextSearchFilter Key="Flavors" Mode="AllPartial" EnableSnippeting="false" Language="en">pech</TextSearchFilter> </State> <RecordListConfig Id="RecList" MaxPages="10"> <Column>Flavors</Column> <RecordsPerPage>5</RecordsPerPage> </RecordListConfig> <SearchAdjustmentConfig Id="SpellCorrect"/> </Request>
Note that in the example, the word "peach" is misspelled as "pech".
<cs:SearchAdjustments Id="SpellCorrect"> <cs:AppliedAdjustment> <cs:TextSearchFilter Key="Flavors" Mode="AllPartial">pech</cs:TextSearchFilter> <cs:AdjustedTerms>peach</cs:AdjustedTerms> </cs:AppliedAdjustment> </cs:SearchAdjustments>
The SearchAdjustments response includes the automatically-corrected term "peach" in the AdjustedTerms element for AppliedAdjustment. The name of the element ("AppliedAdjustment") tells you that the corrected spelling was automatically applied to the query, and the results (2593 records in this example) reflect that correction.
<cs:SearchAdjustments Id="SpellCorrect"> <cs:SuggestedAdjustment RecordCountIfApplied="2593"> <cs:TextSearchFilter Key="Flavors" Mode="AllPartial">pechr</cs:TextSearchFilter> <cs:SuggestedTerms>peach</cs:SuggestedTerms> </cs:SuggestedAdjustment> </cs:SearchAdjustments>
The name of the element ("SuggestedAdjustment") tells you that the term is just a DYM suggestion, which means that it was not applied to the query. The RecordCountIfApplied element shows that if the suggestion had been applied, 2593 records would have been returned. To retrieve those records, re-send the record search query with the suggested term of "peach" for the search term.