Search REST API: Search & Tagging

Overview

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

Service URL

URL_SEARCH/INSTANCE_ID/search?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:




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:

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.

Results + topTrends (empathize) (including categories for the most popular query)

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.


According to the example:

  • 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.
  • topTrends → Popular trends, including category facet for the first one.
  • ebTagging.query → URL to send the query associated tagging event to our tagging service.


According to the previous example:

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


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.

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.


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