Retrieving snippets per query with the API

You can enable snippets for a particular attribute on a per-query basis using the TextSearchFilter type in the Conversation Web Service.

To request snippets with the Conversation Web Service, use the TextSearchFilter type with the specified search interface or text-search enabled attribute. If you specify a search interface, it will be one for which snippeting is enabled for its members in the RECSEARCH_CONFIG XML document. The Conversation Web Service returns snippets as part of the RecordListEntry element (which also returns the records themselves).

Setting the EnableSnippeting attribute to true in the TextSearchFilter type enables snippeting per query, for the specified attribute or search interface. The SnippetLength attribute sets the length of the snippet; the search term specifies the snippet term:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Request xmlns="http://www.endeca.com/MDEX/conversation/3/0">
      <State>
        <TextSearchFilter Key="Description" Mode="AllPartial" 
          EnableSnippeting="true" SnippetLength="4" Language="en">
            gearing
        </TextSearchFilter>
      </State>
      <RecordListConfig Id="RecordList" MaxPages="30">
         <Column>Description</Column>
         <RecordsPerPage>5</RecordsPerPage>
      </RecordListConfig>
    </Request>
  </soap:Body>
</soap:Envelope>
Note: Use these settings only if you need to specify snippeting information for a single attribute for which there is no search interface configured. These settings do not override the settings that globally enable snippeting for members of the search interface in the RECSEARCH_CONFIG > SEARCH_INTERFACE elements.

Response

The following response from the Conversation Web Service returns snippeting information as part of the RecordListEntry:
<cs:ContentElement xsi:type="cs:RecordList" Id="RecordList" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<cs:NumRecords>61157</cs:NumRecords>
<cs:TotalPages>1224</cs:TotalPages>
<cs:RecordRange First="751" Last="800"/>
    ...
<cs:RecordListEntry>
  <cs:Record>
    <Description type="mdex:string">A true multi-sport bike that offers 
      streamlined riding and a revolutionary design. Aerodynamic design lets you 
      ride with the pros, and the gearing will conquer hilly roads.
    </Description>
    <FactSales_RecordSpec type="mdex:string">SO44563-19</FactSales_RecordSpec>
  </cs:Record>
  <cs:ComputedProperties>
    <cs:SearchSnippets Key="Description">
       <cs:SearchSnippet>
         <cs:SnippetText>...and the gearing will conquer hilly </cs:SnippetText>
         <cs:SnippetTerm>gearing<cs:SnippetTerm>
         <cs:SnippetText> the gearing will conquer...</cs:SnippetText>
       </cs:SearchSnippet>
     </cs:SearchSnippets>
   </cs:ComputedProperties>
</cs:RecordListEntry>