Search REST API: Search
Overview
Instructions to use REST API Search service.
Step-by-step guide
Service Name
search
Service URL
URL_SEARCH/INSTANCE_ID/search?INPUT_PARAMETERS
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 |
boost | boosting query in lucene query format | 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 |
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
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
Boosting
Boosting allows you to modify the default ranking pushing to the top the documents matching the specified queries.
Boosting Nike and Rebook products
boost=brand:Nike^2.1 OR brand:Rebook^1.3
boost parameter can be specified multiple times, so multiple queries could be specified as part of a single query using OR (as specified above) or specifying those queries in individual boost parameters.
boost=brand:Nike^2.1&brand:Rebook^1.3
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.
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.
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).
{ 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:
- 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.
{ 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.
{ 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.
- 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
Related articles
-
Search REST API: Search & Tagging (Empathy Knowledge Base)
-
Search REST API: TopClicked (Empathy Knowledge Base)
-
Search REST API: Links (Empathy Knowledge Base)
-
Search REST API: Search (Empathy Knowledge Base)
-
Empathy Search REST API (Empathy Knowledge Base)
-
Search REST API: Search Trends (Empathy Knowledge Base)
-
Search REST API: Browse (Empathy Knowledge Base)
-
Search REST API: Browse & Tagging (Empathy Knowledge Base)
-
Search REST API: FullSearch & Tagging (Empathy Knowledge Base)
-
Search REST API: Empathize (Empathy Knowledge Base)