Instructions to use REST API Search service.
search
URL_SEARCH/INSTANCE_ID/search?INPUT_PARAMETERS
Parameter | Description | Data Type | Mandatory |
---|---|---|---|
q | The query for the request | String | Yes |
lang | Set the language of the query | String | Yes |
start | It is used to paginate results from a query | Integer | Yes |
rows | It is used to paginate results from a query | Integer | Yes |
topTrends.rows | Specify a number of rows for the topTrends section. If this parameter is not specified, the rows param will be used | Integer | No |
filter | Set query filters | String | No |
facet | Set query facets | String | No |
sort | Sort results | String | No |
jsonCallback | Name of the callback that will be executed after the request | String | No |
suggestions.suggestion.docs | Number of results to include for each suggestion | String | No |
equalize | Custom equalize to apply it instead of the active equalize. | String | No |
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.
sort=name_sort asc |
sort=name_sort desc |
sort=price asc |
sort=price desc |
Send us a request with the list of fields that you want to use for FACETING and we will add it to the config.
Example of the api syntax for faceting, with the field brand_facet:
facet={!ex=brand_facet}brand_facet |
To add more facets to the query, you should simply repeat the facet parameter.
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.
NOTE: The following code is just an example, do not copy and paste this for your use
There are different outputs depending of the search 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).
{ content: {}, topTrends: [ ] } |
{ content: { numFound: 14, docs: [ { name: "Samsung Galaxy Note 10.1" }, { name: "Samsung SNH-1010N Smartcam" }, ], facets: [ { facet: "brand", values: [ { value: "samsung", count: 13, filter: "brand:samsung" }, { value: "SBS", count: 1, filter: "brand:SBS" } ] } ] }, 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" } ] } |
According to the previous example:
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.
{ 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" } ] } |
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.
{ content: { suggestions: [ { suggestion: "panasonic", numFound: 101, docs: [ { name: "Panasonic KX-TG 8621" }, { name: "Panasonic KX-TGP 550" } ] }, { suggestion: "samsung", numFound: 14, docs: [ { name: "Samsung Galaxy Note 10.1" }, { name: "Samsung SNH-1010N Smartcam" } ] } ] }, topTrends: [ ] } |
The suggestions node will contain one or more suggestions for each term or combination of terms contained in the query typed by the user.