Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

Instructions to use REST API Search service.

Step-by-step guide

Service Name

search

Service URL

URL_EMPATHYBROKER/services/search?INPUT_PARAMETERS

Input Parameters

ParameterDescriptionData TypeMandatory
qThe query for the requestStringYes
langSet the language of the queryStringYes
startIt is used to paginate results from a queryIntegerYes
rowsIt is used to paginate results from a queryIntegerYes
topTrends.rowsSpecify a number of rows for the topTrends section. If this parameter is not specified, the rows param will be usedIntegerNo
filterSet query filtersStringNo
facetSet query facetsStringNo
sortSort resultsStringNo
jsonCallbackName of the callback that will be executed after the requestStringNo
suggestionsNumber of results to include for each suggestionStringNo

Sorting

Send us a request with the fields you want to use for SORTING and we will configure it. 

You can find below some code samples of the api syntax for sorting.

title A-Z
Code Block
sort=name_sort asc
title Z-A
Code Block
sort=name_sort desc
price min to max
Code Block
sort=price asc
price max to min
Code Block
sort=price desc

Faceting

Send us a request with the list of fields that you want to use for FACETING and we will add it to the config.

...

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

Top Trends Faceting

It requires EB version 3.8+. Send us a request if you like to upgrade your EB instance.

Once the feature is activated, you don't need to specify any new parameter on the query. See below (section "Output - Results + topTrends") to check how the format of the response is.

Examples

NOTE: The following code is just an example, do not copy and paste this for your use

Output

There are different outputs 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).

...

  • 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.
  • facets → filters, will contain one entry for each facet contained in the request using the facets param or directly configured in the search service by the EB Team.
  • topTrends → Popular trends, including category facet for the first one.

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.

Code Block
languagejs
{
    content: {
        numFound: 2,
        docs: [
                {
                    name: "Samsung Galaxy Note 10.1"
                },
                {
                    name: "Samsung SNH-1010N Smartcam"
                },
        ],
        facets: [
                {
                    facet: "brand",
                    values: [
                        {
                            value: "samsung",
                            count: 13,
                            filter: "brand:samsung"
                        },
                        {
                            value: "fitbit",
                            count: 1,
                            filter: "brand:fitbit"
                        }
                    ]
                }
        ],
        spellchecked: "samsung"
    },
    topTrends: [ 
        {
            title: "<b>samsung</b>",
            title_raw: "samsung"
        }
    ]
}


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.

...

  • 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

Filter by label (Content by label)
cqllabel = "empathy-search-api-rest" and space = currentSpace()