This post describes the Sitecore Experience Accelerator Search Service. You will find here a description of each parameter, example values and server responses
Introduction
Sitecore Experience Accelerator Search Service is a search endpoint used by Search feature. In this post, you will get know how to use it, what are the available parameters and how an example response looks like.
Endpoint
Search route is registered in the Initialize
pipeline via Sitecore.XA.Foundation.Search.Pipelines.Initialize.InitializeRouting
class.
1
RouteTable.Routes.MapHttpRoute(route + "sxa", route + "sxa/{controller}/{action}").RouteHandler = new SessionHttpControllerRouteHandler();
SXA delivers SearchController
with two actions inside:
Results
Facets
Results
Description: Runs search and returns results.
Endpoint url: https://domain/sxa/search/results
Parameters:
v
- rendering variant ID used during rendering each search result item. Output will be rendered intoHtml
parameter. If unspecified null value will be returned 1,q
- query term,s
- search scope ID for narrowing search results 2,l
- comma or pipe separated list of language versions to include,g
- latitude and longitude of the geolocation used for spatial search,n
- comma or pipe separated list of fields used to render item’s name,o
- ordering column and sorting direction,e
- offset, i.e. number of top search results to exclude,p
- page size, i.e. number of search results to return,sig
- signature of the search result component. 3
Example parameters:
Parameter | Value |
---|---|
v | {BAFF04C0-7332-4B72-A108-EE9814C62F16} |
q | Renderings |
s | {BAFF04C0-7332-4B72-A108-EE9814C62F16} |
l | en|pl |
g | 51.8084262|16.285813400000052 |
n | Title,Content |
o | Title,Descending |
e | 40 |
p | 10 |
sig | 123 |
Example result:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"TotalTime": 111,
"CountTime": 4,
"QueryTime": 91,
"Signature": null,
"Index": "sitecore_master_index",
"Count": 2,
"Results": [{
"Id": "1abe17cb-1e86-4ff8-bcee-909b6b0404dd",
"Language": "en",
"Path": "/sitecore/content/SXA Reference/Playground/int/Home/renderings",
"Url": "/renderings",
"Name": "Renderings",
"Html": null
}, {
"Id": "81003e8d-4232-433d-849e-6ca9574b5bd1",
"Language": "en",
"Path": "/sitecore/content/SXA Reference/Playground/int/Home/movies",
"Url": "/movies",
"Name": "Movies",
"Html": null
}]
}
Facets
Description: Runs search and returns facets.
Endpoint url: https://domain/sxa/search/facets
Parameters:
f
- comma or pipe separated list of facets to return,q
- query term user entered into the search box,s
- scope ID for narrowing down search result 2,l
- comma or pipe separated list of language versions to include,g
- latitude and longitude of the geolocation used for spatial search,sig
- signature of the search result component 3.
Example parameters:
Parameter | Value |
---|---|
f | SxaTags,Movie Type |
q | Renderings |
s | {BAFF04C0-7332-4B72-A108-EE9814C62F16} |
l | en|pl |
g | 51.8084262|16.285813400000052 |
sig | 123 |
Example result:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"TotalTime": 31,
"QueryTime": 4,
"Signature": null,
"Index": "sitecore_master_index",
"Facets": [{
"Key": "sxatags",
"Name": "sxatags",
"Values": [{
"Name": "composites",
"Count": 4
}, {
"Name": "context",
"Count": 2
}, {
"Name": "page content",
"Count": 10
}]
}]
}
Summary
Playing with search endpoint should be much easier right now. If you feel that you lack some knowledge about SXA features make sure you are familiar with links below.
In case of any problems with search feel free to ask in the comments section below or reach us on #sxa slack channel.
1. Rendering variants are configurable adaptations of the default renderings. More: Create a rendering variant
2. Search scopes can be used to limit search results based on conditions. More: SXA Search