Search REST API: FullSearch & Tagging

Overview

The purpose of this guide is to provide the steps required to integrate search service, links and empathize via REST API and use the returned tagging urls for each event (query, click, add2cart, ...).

Service URL

URL_SEARCH/INSTANCE_ID/fullsearch?INPUT_PARAMETERS

URI Parameters

Parameter NameScopeDescriptionTypeMandatoryDefault Value
qsearchThe query for the requestString(tick)
langsearch & taggingSet the language used on this requestString(tick)
sessionsearch & taggingSet the session used on this requestString(tick)
usersearch & taggingSet the user used on this requestString(tick)
scopesearch & taggingSet the scope used on this requestString(tick)
origintaggingSet the origin of the request (default, GA, partials, ...)String(error)
startsearchThe number of results to omit from the start of the result set (search pagination)Integer(error)0
rowssearchNumber of results to return (search pagination)Integer(error)10
filtersearchSet query filters to applyString(error)
facetsearchSet query facets to returnString(error)
sortsearchSort resultsString(error)
jsonCallbacksearchName of the callback that will be executed after the requestString(error)
suggestions.suggestion.docssearchNumber of results to include for each suggestionString(error)

Search functionalities 

Sorting

First of all, you need to send a request with the fields that you want to use for this purpose (ie: price). Then you'll be able to use the sort param to sort the results.

The request param used for this purpose is sort and the format of the value is: field order

Note: this param can be send only one time.

Below, you can find some samples for sorting:

title A-Z
sort=name_sort asc


title Z-A
sort=name_sort desc


price min to max
sort=price asc


price max to min
sort=price desc

Faceting

First of all, you need to send a request with the fields that you want to use for this purpose (ie: category). Then you'll be able to use the facet param to request facets.

Note: to add more facets to the query, you should simply repeat the facet parameter.

Below, you can find a sample to request a facet over brand_facet field:

facet={!ex=brand_facet}brand_facet

Filtering

...

Code examples

NOTE: The following code is just an example, don't copy & paste this for your use

Response format

There are different output formats depending of the search results.

Links + Top Trends (empathize) (including categories for the most popular query) + Results 

By default, the service will return two JSON nodes, one for the search results (content) and another one for the topTrends (more popular queries and categories for the first one). 

Moreover this JSON includes one node per product with the tagging urls and one additional node with the search tagging url.


Default Output Format
{
  topTrends: [ ],
  direct: [ ],
  banner: [ ],
  promoted: [ ],
  content: {
    numFound: 123,
    docs: [],
    facets: [],
    [... more fields ...]
  },
  ebTagging: {
    query: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/query?q=QUERY&scope=default&lang=es&totalHits=10&page=1"
  }
}

According to the example:

  • topTrends → Popular trends, including category facet for the first one.
  • direct → Direct links configured in the dashboard.
  • banner → Banner links configured in the dashboard.
  • promoted → Promoted links configured in the dashboard.
  • numFound → number of the documents returned by the service.
  • docs → Json array with the documents returned by the service. Each one will contain all the fields configured to be returned by the search service.
  • ebTagging.query → URL to send the query associated tagging event to our tagging service.


Docs content
docs: [
  {
    name: "Samsung Galaxy Note 10.1",
    [... more fields ...]
	ebTagging: {
	  click: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/click?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	  add2cart: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/add2cart?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	  wishlist: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/wishlist?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	  conversion: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/conversion?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4"
	}
  },
  {
    name: "Samsung SNH-1010N Smartcam",
    [... more fields ...]
	ebTagging: {
	  click: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/click?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	  add2cart: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/add2cart?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	  wishlist: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/wishlist?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	  conversion: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/conversion?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4"
    }
  },
]

According to the previous example:

  • ebTagging.* → URLs to send the product associated tagging events to our tagging service. 


TopTrends content
topTrends: [ 
  {
    title: "<b>sams</b>ng",
    title_raw: "samsung",
    facets: [
      {
        facet: "rootCategories_facet"
        values: [
          {
            value: "Mobile Phones",
            count: 5,
            filter: "{!tag=rootFilter}rootCategories_facet:Mobile Phones"
          },
          {
            value: "Phone Accessories",
            count: 3,
            filter: "{!tag=rootFilter}rootCategories_facet:Phone Accessories"
          }
        ]
      }
    ]
  },
  {
    title: "<b>sams</b>ung galaxy",
    title_raw: "samsung galaxy"
  },
  {
    title: "tablet <b>sams</b>ung",
    title_raw: "tablet samsung"
  }
]
Facets content
facets: [
  {
    facet: "brand",
    values: [
      {
        value: "samsung",
        count: 13,
        filter: "brand:samsung"
      },
      {
        value: "fitbit",
        count: 1,
        filter: "brand:fitbit"
      }
    ]
  }
]


Facets content
banner: [
    {
        id: "546dd382e4b08960f81c1392",
        title: "Promoted Banner Test Link",
        subtitle: "",
        portal: "",
        scope: "",
        title_raw: "Promoted Banner Test Link",
        subtitle_raw: "",
        url: "http://www.testlink.com",
        trackable_url: "TRACKABLE_TEST_LINK",
        imagename: "IMAGE_NAME"
    }
]
Facets content
 promoted: [
    {
        id: "546dd382e4b08960f81c1395",
        title: "Promoted Test Link",
        subtitle: "",
        portal: "",
        scope: "",
        title_raw: "Promoted Test Link",
        subtitle_raw: "",
        url: "http://www.testlink.com",
        trackable_url: "TRACKABLE_TEST_LINK",
        imagename: "IMAGE_NAME"
    }
]
Facets content
 direct: [
    {
        id: "54a17583e4b08f7d3fcfd8a9",
        title: "Direct Test Link",
        subtitle: "",
        portal: "",
        scope: "",
        title_raw: "Direct Test Link",
        subtitle_raw: "",
        url: "http://www.testlink.com",
        trackable_url: "TRACKABLE_TEST_LINK",
        imagename: "IMAGE_NAME"
    }
]

Spellcheck + topTrends (empathize)

The search engine can detect grammatical errors and automatically correct it, for example searching by "sammsung" the system will suggest "samsung" in the spellchecked node.

Default Output Format + spellcheck
{
  topTrends: [ ],
  direct: [ ],
  banner: [ ],
  promoted: [ ],
  content: {
    numFound: 2,
    docs: [],
    facets: [],
    spellchecked: "samsung"
  },
  ebTagging: {
    query: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/query?q=QUERY&scope=default&lang=es&totalHits=10&page=1"
  }
}

Suggestions + topTrends (empathize)

For example searching by "samsung panasonic" the search engine detects than there're no products with both terms but there are products with each term separately.

Default Output Format + suggestions
{
  topTrends: [ ],
  direct: [ ],
  banner: [ ],
  promoted: [ ],
  content: {
    suggestions: [
      {
        suggestion: "panasonic",
        numFound: 101,
        docs: [
          {
            name: "Panasonic KX-TG 8621",
            [... more fields ...]
		    ebTagging: {
	  	      click: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/click?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	          add2cart: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/add2cart?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	          wishlist: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/wishlist?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	          conversion: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/conversion?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4"
	  	    }
          },
          {
            name: "Panasonic KX-TGP 550",
            [... more fields ...]
		    ebTagging: {
		  	  click: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/click?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	          add2cart: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/add2cart?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	          wishlist: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/wishlist?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4",
	          conversion: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/conversion?q=QUERY&scope=default&lang=es&url=PRODUCT_URL&page=1&productId=PRODUCT_ID&title=PRODUCT_NAME&type=4"
		    }
          }
        ]
      },
      {
        suggestion: "samsung",
        numFound: 14,
        docs: [
          {
            name: "Samsung Galaxy Note 10.1",
            [... more fields ...]
		    ebTagging: {
		      ...
	        }
          },
          {
            name: "Samsung SNH-1010N Smartcam",
            [... more fields ...]
		    ebTagging: {
		      ...
		    }
          }
        ]
      }
    ]
  },
  ebTagging: {
	query: "URL_EMPATHYBROKER/tagging/v1/track/CLIENT_ID/query?q=QUERY&scope=default&lang=es&totalHits=10&page=1"
  }
}


The suggestions node will contain one or more suggestions for each term or combination of terms contained in the query typed by the user.

  • suggestion → term suggested by the search engine
  • numFound → number of results that the search engine will return searching using this suggestion
  • docs → By default, the search engine will return a sample of the results using this suggestion