ContentSearch resource (Shop API 23.2)

Summary

Http Method Resource Description
GET /content_search Provides keyword and refinement search functionality for content assets. The search result contains only content that is online and assigned to a folder.

Search content

Provides keyword and refinement search functionality for content assets. The search result contains only content that is online and assigned to a folder.

Url

GET http://hostname:port/dw/shop/v23_2/content_search?q={String}&refine={String}&sort={String}&start={Integer}&count={Integer}&locale={String}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT.
None No authentication.

Response Document

ContentSearchResult

Query Parameters

Parameter Type Description Constraints
count Integer The maximum number of instances per request. Default value is 25. maxIntegerValue=200, minIntegerValue=1
locale String The locale context.  
q String The query phrase to search for. maxLength=50
refine String Parameter that represents a refinement attribute/value(s) pair. Refinement attribute id and value(s) are separated by '='. Multiple values are supported by a sub-set of refinement attributes and can be provided by separating them using a pipe (URL encoded = "|"). Value ranges can be specified like this: refine=foo=(100..500) Multiple refine parameters can be provided by adding an underscore in combination with an integer counter right behind the parameter name and a counter range 1..9. I.e. refine_1=c_refinementType=type1|type2|type3. The following system refinement attribute ids are supported:
  • fdid: Allows to refine per single content folder id. Multiple folder ids are not supported.
 
sort String Parameter that represents a sorting attribute/value(s) pair. Sorting attribute id and value are separated by '='. The value describes the sort direction. Possible values are 'asc' and 'desc', for ascending or descending sort direction. I.e. sort=c_myAttribute=desc. Precondition: You have to select your sorting attributes in Business Manager > YourSite > Search Indexes > Content Index > Sorting Attributes.  
start Integer The result set index to return the first instance for. Default value is 0. minIntegerValue=0

Customization

This Resource supports server-side customization.

Extension Point Method Detail
dw.ocapi.shop.content_search.beforeGET

beforeGET () : Status

The function is called before the request will be processed.

Returns:
a non-null Status ends the hook execution
dw.ocapi.shop.content_search.modifyGETResponse

modifyGETResponse (doc : ContentSearchResult ) : Status

The function is called after the request has been processed.

Parameters:
doc - the document
Returns:
a non-null Status ends the hook execution

Sample

REQUEST:
GET /dw/shop/v23_2/content_search?q=about&refine=fdid=about-us HTTP/1.1
Host: example.com
Accept: application/json

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=900,must-revalidate
Content-Length: 11318

{
  "_v" : "23.2",
  "_type":"content_search_result",
  "count" : 4,
  "hits" : [ {
    "description" : "Welcome to Salesforce Commerce Cloud. At Salesforce Commerce Cloud we recognize all good success starts with people ...",
    "id" : "jobs-landing",
    "name" : "Jobs Landing Page",
    "c_body" : "<div><h1>Careers at Salesforce Commerce Cloud</h1><hr /><p>Welcome to Salesforce Commerce Cloud ... "
  }, {
    "description" : "It all started with a series of observations: eCommerce merchandising and marketing innovation is what generates the revenue ...",
    "id" : "about-us",
    "name" : "About Us",
    "c_body" : "<h1">About Us</h1><h2>It all started with a series of observations ...",
    "c_customCSSFile" : "http://example.com/on/demandware.static/Sites-SiteGenesis-Site/Sites-SiteGenesis-Library/default/v1365077029384/css/aboutus.css"
  }, {
    "description" : "Interested in getting more information about Salesforce Commerce Cloud and our On-Demand eCommerce solution? Here is information on office locations ...",
    "id" : "contact-us-details",
    "name" : "Contact Us Details",
    "c_body" : "<h5>Connect with Salesforce Commerce Cloud</h5><div><p>Interested in getting more information ..."
  }, {
    "description" : "With Salesforce Commerce Cloud ecommerce, they're spending more time leading with merchandising and marketing. They're in complete control over their site ...",
    "id" : "history",
    "name" : "Our Story",
    "c_body" : "<p><strong>It all started with a series of observations:</strong></p><ul><li>eCommerce merchandising ..."
  } ],
  "query" : "about",
  "refinements" : [ {
    "attribute_id" : "fdid",
    "label" : "About Us",
    "values" : [ {
      "hit_count" : 4,
      "label" : "About Salesforce Commerce Cloud",
      "value" : "about-us",
      "values" : [ {
        "hit_count" : 1,
        "label" : "Our Story",
        "value" : "our-story"
      }, {
        "hit_count" : 0,
        "label" : "Our Team",
        "value" : "our-team"
      }, {
        "hit_count" : 0,
        "label" : "As Seen In",
        "value" : "as-seen-in"
      }, {
        "hit_count" : 1,
        "label" : "Contact Us",
        "value" : "contact-us-new"
      }, {
        "hit_count" : 1,
        "label" : "Join Us",
        "value" : "employment"
      } ]
    }, {
      "hit_count" : 0,
      "label" : "Customer Service",
      "value" : "customer-service"
    } ]
  } ],
  "selected_refinements" : {
    "fdid" : "about-us"
  },
  "start" : 0,
  "total" : 4
}
X OCAPI versions 15.x and 16.x will be retired on March 31, 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.