Skip to content

Commit f129503

Browse files
committed
feat: add searchFacetValues endpoint
1 parent bd88b32 commit f129503

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
searchForFacetValuesResponse:
2+
type: object
3+
additionalProperties: false
4+
properties:
5+
results:
6+
type: array
7+
description: Search for facet values results.
8+
items:
9+
$ref: '#/searchForFacetValuesResults'
10+
11+
searchForFacetValuesResults:
12+
type: object
13+
additionalProperties: false
14+
required:
15+
- facetHits
16+
- exhaustiveFacetsCount
17+
- indexName
18+
x-discriminator-fields:
19+
- facetHits
20+
properties:
21+
indexName:
22+
type: string
23+
facetHits:
24+
type: array
25+
description: Matching facet values.
26+
items:
27+
title: facetHits
28+
type: object
29+
additionalProperties: false
30+
required:
31+
- value
32+
- highlighted
33+
- count
34+
properties:
35+
value:
36+
description: Facet value.
37+
example: 'Mobile phone'
38+
type: string
39+
highlighted:
40+
$ref: '../../../common/schemas/HighlightResult.yml#/highlightedValue'
41+
count:
42+
description: Number of records with this facet value. [The count may be approximated](https://support.algolia.com/hc/en-us/articles/4406975248145-Why-are-my-facet-and-hit-counts-not-accurate-).
43+
type: integer
44+
exhaustiveFacetsCount:
45+
type: boolean
46+
description: |
47+
Whether the facet count is exhaustive (true) or approximate (false).
48+
For more information, see [Why are my facet and hit counts not accurate](https://support.algolia.com/hc/en-us/articles/4406975248145-Why-are-my-facet-and-hit-counts-not-accurate-).
49+
processingTimeMS:
50+
$ref: '../../../common/schemas/SearchResponse.yml#/processingTimeMS'
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
post:
2+
tags:
3+
- Search
4+
operationId: searchForFacetValues
5+
x-use-read-transporter: true
6+
x-cacheable: true
7+
x-acl:
8+
- search
9+
summary: Search for facet values
10+
description: |
11+
Searches for values of a specified facet attribute on the composition's main source's index.
12+
13+
- By default, facet values are sorted by decreasing count.
14+
You can adjust this with the `sortFacetValueBy` parameter.
15+
- Searching for facet values doesn't work if you have **more than 65 searchable facets and searchable attributes combined**.
16+
parameters:
17+
- $ref: '../../common/parameters.yml#/compositionID'
18+
- name: facetName
19+
description: |
20+
Facet attribute in which to search for values.
21+
22+
This attribute must be included in the `attributesForFaceting` index setting with the `searchable()` modifier.
23+
in: path
24+
required: true
25+
schema:
26+
type: string
27+
requestBody:
28+
content:
29+
application/json:
30+
schema:
31+
title: searchForFacetValuesRequest
32+
type: object
33+
additionalProperties: false
34+
properties:
35+
params:
36+
title: searchForFacetValuesParams
37+
type: object
38+
properties:
39+
query:
40+
$ref: '../../../common/schemas/SearchParams.yml#/query'
41+
maxFacetHits:
42+
$ref: '../../../common/schemas/IndexSettings.yml#/maxFacetHits'
43+
searchQuery:
44+
$ref: '../../common/schemas/SearchParams.yml#/searchParams'
45+
responses:
46+
'200':
47+
description: OK
48+
content:
49+
application/json:
50+
schema:
51+
$ref: '../../common/schemas/SearchForFacetValuesResponse.yml#/searchForFacetValuesResponse'
52+
'400':
53+
$ref: '../../../common/responses/BadRequest.yml'
54+
'402':
55+
$ref: '../../../common/responses/FeatureNotEnabled.yml'
56+
'403':
57+
$ref: '../../../common/responses/MethodNotAllowed.yml'
58+
'404':
59+
$ref: '../../../common/responses/IndexNotFound.yml'

specs/composition/spec.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ paths:
5858
# ########################
5959
/1/compositions/{compositionID}/run:
6060
$ref: 'paths/search/run.yml'
61+
/1/compositions/{compositionID}/facets/{facetName}/query:
62+
$ref: 'paths/search/searchForFacetValues.yml'
6163

6264
# #########################
6365
# ### Objects Endpoints ###

0 commit comments

Comments
 (0)