Skip to content

Commit 333368a

Browse files
kai687shortcuts
andauthored
feat(specs): query suggestions (#1740)
Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
1 parent 90e945e commit 333368a

24 files changed

+413
-231
lines changed

.github/.cache_version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.5
1+
0.0.6
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
logLevel:
1+
LogLevel:
2+
title: level
23
type: string
3-
enum: [INFO, SKIP, ERROR]
4-
description: type of the record, can be one of three values (INFO, SKIP or ERROR).
4+
description: |
5+
The type of log entry.
6+
7+
- `SKIP`. A query is skipped because it doesn't match the conditions for successful inclusion. For example, when a query doesn't generate enough search results.
8+
- `INFO`. An informative log entry.
9+
- `ERROR`. The Query Suggestions process encountered an error.
10+
enum:
11+
- SKIP
12+
- INFO
13+
- ERROR
Lines changed: 7 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,7 @@
1-
SourceIndex:
2-
type: object
3-
additionalProperties: false
4-
required:
5-
- indexName
6-
properties:
7-
indexName:
8-
$ref: '#/indexName'
9-
analyticsTags:
10-
$ref: '#/analyticsTags'
11-
facets:
12-
$ref: '#/facets'
13-
minHits:
14-
$ref: '#/minHits'
15-
minLetters:
16-
$ref: '#/minLetters'
17-
generate:
18-
$ref: '#/generate'
19-
external:
20-
$ref: '#/external'
21-
22-
SourceIndexExternal:
23-
type: object
24-
additionalProperties: false
25-
required:
26-
- query
27-
- count
28-
properties:
29-
query:
30-
type: string
31-
description: The suggestion you would like to add.
32-
count:
33-
type: integer
34-
description: The measure of the suggestion relative popularity.
35-
36-
SourceIndices:
37-
type: array
38-
items:
39-
$ref: '#/SourceIndex'
40-
description: List of source indices used to generate a Query Suggestions index.
41-
42-
QuerySuggestionsIndexParam:
43-
type: object
44-
additionalProperties: false
45-
required:
46-
- sourceIndices
47-
properties:
48-
sourceIndices:
49-
$ref: '../common/parameters.yml#/SourceIndices'
50-
languages:
51-
type: array
52-
items:
53-
type: string
54-
description: De-duplicate singular and plural suggestions. For example, let's say your index contains English content, and that two suggestions “shoe” and “shoes” end up in your Query Suggestions index. If the English language is configured, only the most popular of those two suggestions would remain.
55-
exclude:
56-
type: array
57-
items:
58-
type: string
59-
description: List of words and patterns to exclude from the Query Suggestions index.
60-
61-
QuerySuggestionsIndexWithIndexParam:
62-
allOf:
63-
- $ref: '#/QuerySuggestionsIndexParam'
64-
- type: object
65-
title: IndexName
66-
additionalProperties: false
67-
required:
68-
- indexName
69-
properties:
70-
indexName:
71-
type: string
72-
description: Index name to target.
73-
74-
indexName:
75-
type: string
76-
description: Source index name.
77-
78-
analyticsTags:
79-
type: array
80-
items:
81-
type: string
82-
default: []
83-
description: List of analytics tags to filter the popular searches per tag.
84-
85-
facets:
86-
type: array
87-
items:
88-
type: object
89-
default: []
90-
description: List of facets to define as categories for the query suggestions.
91-
92-
minHits:
93-
type: integer
94-
description: Minimum number of hits (e.g., matching records in the source index) to generate a suggestions.
95-
96-
minLetters:
97-
type: integer
98-
description: Minimum number of required letters for a suggestion to remain.
99-
100-
generate:
101-
type: array
102-
items:
103-
type: array
104-
items:
105-
type: string
106-
default: []
107-
description: List of facet attributes used to generate Query Suggestions. The resulting suggestions are every combination of the facets in the nested list (e.g., (facetA and facetB) and facetC).
108-
example: '[[facetA, facetB], [facetC]]'
109-
110-
external:
111-
type: array
112-
items:
113-
$ref: '#/SourceIndexExternal'
114-
description: List of external indices to use to generate custom Query Suggestions.
1+
IndexName:
2+
name: indexName
3+
in: path
4+
required: true
5+
description: Query Suggestions index name.
6+
schema:
7+
$ref: './schemas/QuerySuggestionsIndexName.yml'
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
description: Bad Request.
2+
content:
3+
application/json:
4+
schema:
5+
$ref: '../schemas/BaseResponse.yml'
6+
examples:
7+
IndexNameRequired:
8+
summary: Index name required.
9+
value: {'status': 400, 'message': 'IndexName cannot be empty'}
10+
SourceIndicesRequired:
11+
summary: Source indices required.
12+
value:
13+
'status': 400
14+
'message': 'Invalid body "sourceIndices needs to contain at least one index".'
15+
16+
SourceIndexNameRequired:
17+
summary: Source index name required.
18+
value:
19+
'status': 400
20+
'message': 'Invalid body "every source index must have an `indexName`".'
21+
22+
MinHitsPositive:
23+
summary: MinHits must be positive.
24+
value:
25+
'status': 400
26+
'message': 'Invalid body "every source index `minHits` must be positive".'
27+
28+
MinLettersPositive:
29+
summary: MinLetters must be positive.
30+
value:
31+
'status': 400
32+
'message': 'Invalid body "every source index `minLetters` must be positive".'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
description: Internal Server Error.
2+
content:
3+
application/json:
4+
schema:
5+
$ref: '../schemas/BaseResponse.yml'
6+
examples:
7+
Error:
8+
description: This error can happen if you use a non-existing `indexName` as a path parameter when trying to update or delete a Query Suggestions configuration.
9+
value: {'status': 500, 'message': 'Internal Server Error'}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
description: Not Found.
2+
content:
3+
application/json:
4+
schema:
5+
$ref: '../schemas/BaseResponse.yml'
6+
examples:
7+
NotFound:
8+
summary: Index not found.
9+
value: {'status': 404, 'message': 'Not Found'}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
description: Unauthorized
2+
content:
3+
application/json:
4+
schema:
5+
$ref: '../schemas/BaseResponse.yml'
6+
examples:
7+
Unauthorized:
8+
summary: Wrong region.
9+
description: |
10+
Make sure to make your request to the server corresponding to your region.
11+
12+
You can check the region for your application in the [Algolia dashboard](https://dashboard.algolia.com/account/infrastructure/analytics).
13+
value:
14+
'status': 401
15+
'message': 'The log processing region does not match'
16+
17+
InvalidCredentials:
18+
summary: Invalid credentials.
19+
description: Your application ID or API key is wrong.
20+
value: {'status': 401, 'message': 'Invalid credentials'}
21+
WrongAPIKey:
22+
summary: Admin API key required.
23+
description: Your API key is not the Admin API key for your application.
24+
value:
25+
{'status': 401, 'message': 'The admin API key is required'}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
description: Unprocessable Entity.
2+
content:
3+
application/json:
4+
schema:
5+
$ref: '../schemas/BaseResponse.yml'
6+
examples:
7+
UnprocessableEntity:
8+
summary: Configuration already exists.
9+
value:
10+
'status': 422
11+
'message': 'Configuration already exists for index: test-qs'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
type: object
2+
additionalProperties: false
3+
properties:
4+
status:
5+
type: integer
6+
description: HTTP status code.
7+
message:
8+
type: string
9+
description: Details about the response, such as error messages.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
title: facet
2+
description: Facet to use as category.
3+
type: object
4+
additionalProperties: false
5+
properties:
6+
attribute:
7+
type: string
8+
description: Facet name.
9+
amount:
10+
type: integer
11+
description: Number of suggestions.

0 commit comments

Comments
 (0)