Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit 1d6afe2

Browse files
dureuillmacraig
andauthored
Score details (#252)
* ranking score spec * search API changes * telemetry policies score * open api * Fix typos in spec Co-authored-by: Maria Craig <marycraig90@gmail.com> * Add multi search telemetry --------- Co-authored-by: Maria Craig <marycraig90@gmail.com>
1 parent 57c2e95 commit 1d6afe2

4 files changed

Lines changed: 437 additions & 28 deletions

File tree

open-api.yaml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,157 @@ components:
117117
- start
118118
- length
119119
description: Starting position and length in bytes of the matched term in the returned value
120+
order:
121+
type: integer
122+
description: The order that this ranking rule was applied
123+
customRankingRuleDetails:
124+
type: object
125+
properties:
126+
order:
127+
$ref: '#/components/schemas/order'
128+
value:
129+
type:
130+
- string
131+
- number
132+
- point
133+
description: The value that was used for sorting this document
134+
distance:
135+
type: number
136+
description: The distance between the target point and the geoPoint in the document
137+
required:
138+
- order
139+
- value
140+
description: Custom rule in the form of either `attribute:direction` or `_geoPoint(lat, lng):direction`.
141+
score:
142+
type: number
143+
description: |
144+
The relevancy score of a document according to a ranking rule and relative to a search query. Higher is better.
145+
146+
`1.0` indicates a perfect match, `0.0` no match at all (Meilisearch should not return documents that don't match the query).
147+
rankingScoreDetails:
148+
type: object
149+
properties:
150+
words:
151+
type: object
152+
properties:
153+
order:
154+
$ref: '#/components/schemas/order'
155+
matchingWords:
156+
type: integer
157+
description: the number of words from the query found
158+
maxMatchingWords:
159+
type: integer
160+
score:
161+
$ref: '#/components/schemas/score'
162+
required:
163+
- order
164+
- matchingWords
165+
- maxMatchingWords
166+
- score
167+
typo:
168+
type: object
169+
properties:
170+
order:
171+
$ref: '#/components/schemas/order'
172+
typoCount:
173+
type: integer
174+
description: The number of typos to correct in the query to match that document.
175+
maxTypoCount:
176+
type: integer
177+
description: The maximum number of typos that can be corrected in the query to match a document.
178+
score:
179+
$ref: '#/components/schemas/score'
180+
required:
181+
- order
182+
- typoCount
183+
- maxTypoCount
184+
- score
185+
proximity:
186+
type: object
187+
properties:
188+
order:
189+
$ref: '#/components/schemas/order'
190+
score:
191+
$ref: '#/components/schemas/score'
192+
required:
193+
- order
194+
- score
195+
attribute:
196+
type: object
197+
properties:
198+
order:
199+
$ref: '#/components/schemas/order'
200+
attribute_ranking_order_score:
201+
type: number
202+
description: |
203+
Score computed depending on the first attribute each word of the query appears in.
204+
205+
The first attribute in the `searchableAttributes` list yields the highest score, the last attribute the lowest.
206+
query_word_distance_score:
207+
type: number
208+
description: |
209+
Score computed depending on the position the attributes where each word of the query appears in.
210+
211+
Words appearing in an attribute at the same position as in the query yield the highest score. The greater the distance to the position
212+
in the query, the lower the score.
213+
score:
214+
$ref: '#/components/schemas/score'
215+
required:
216+
- order
217+
- attribute_ranking_order_score
218+
- query_word_distance_score
219+
- score
220+
exactness:
221+
type: object
222+
properties:
223+
order:
224+
$ref: '#/components/schemas/order'
225+
matchType:
226+
type: string
227+
description: |
228+
One of `exactMatch`, `matchesStart` or `noExactMatch`.
229+
- `exactMatch`: the document contains an attribute that exactly matches the query.
230+
- `matchesStart`: the document contains an attribute that exactly starts with the query.
231+
- `noExactMatch`: any other document.
232+
score:
233+
$ref: '#/components/schemas/score'
234+
required:
235+
- order
236+
- matchType
237+
- score
238+
additionalProperties:
239+
$ref: '#/components/schemas/customRankingRuleDetails'
240+
description: (EXPERIMENTAL) The ranking score per ranking rule.
241+
examples:
242+
With sort:
243+
words:
244+
order: 0
245+
matchingWords: 7
246+
maxMatchingWords: 7
247+
score: 1.0
248+
"typo":
249+
"order": 1
250+
"typoCount": 0
251+
"maxTypoCount": 0
252+
"score": 1.0
253+
"proximity":
254+
"order": 2,
255+
"score": 1.0
256+
"attribute":
257+
"order": 3
258+
"attribute_ranking_order_score": 1.0
259+
"query_word_distance_score": 1.0
260+
"score": 1.0
261+
"title:asc":
262+
"order": 4
263+
"value": "batman: the dark knight returns, part 1"
264+
"release_date:desc":
265+
"order": 5
266+
"value": 1345507200.0
267+
"exactness":
268+
"order": 6
269+
"matchType": "exactMatch"
270+
"score": 1.0
120271
hit:
121272
type: object
122273
additionalProperties: true
@@ -168,6 +319,15 @@ components:
168319
properties:
169320
'':
170321
$ref: '#/components/schemas/matchesPosition'
322+
_rankingScore:
323+
type: number
324+
description: Only present if showRankingScore = `true`. The ranking score of that document.
325+
_rankingScoreDetails:
326+
type: object
327+
description: (EXPERIMENTAL) Only present if showRankingScoreDetails = `true`. The ranking score of each ranking rule for that document.
328+
properties:
329+
'':
330+
$ref: '#/components/schemas/rankingScoreDetails'
171331
attribute:
172332
type:
173333
- string
@@ -712,6 +872,14 @@ components:
712872
type: boolean
713873
description: Defines whether an `_matchesPosition` object that contains information about the matches should be returned or not.
714874
default: false
875+
showRankingScore:
876+
type: boolean
877+
description: Defines whether a `_rankingScore` number representing the relevancy score of that document should be returned or not.
878+
default: false
879+
showRankingScoreDetails:
880+
type: boolean
881+
description: (EXPERIMENTAL) Defines whether a `_rankingScoreDetails` object containing information about the score of that document for each ranking rule should be returned or not.
882+
default: false
715883
matchingStrategy:
716884
type: string
717885
description: Defines which strategy to use to match the query terms within the documents as search results. Two different strategies are available, `last` and `all`. By default, the `last` strategy is chosen.
@@ -762,6 +930,7 @@ components:
762930
attributesToHighlight:
763931
- overview
764932
showMatchesPosition: true
933+
showRankingScore: true
765934
wordsMatchingStrategy: all
766935
error:
767936
title: error

text/0034-telemetry-policies.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ The collected data is sent to [Segment](https://segment.com/). Segment is a plat
191191
| `clear_all` | `true` if `DELETE /indexes/:indexUid/documents` endpoint was used in this batch, otherwise `false` | false | `Documents Deleted` |
192192
| vector_store | Whether the [vector store](./0193-experimental-features.md#vector-store) feature is enabled. | `true` | `Experimental features Updated` |
193193
| score_details | Whether the [score details](./0193-experimental-features.md#score-details) feature is enabled. | `true` | `Experimental features Updated` |
194+
| scoring.show_ranking_score | Was `showRankingScore` used in the aggregated event? If yes, `true`, otherwise `false` | `false` | `Documents Searched POST`, `Documents Searched GET`, `Documents Searched by Multi-Search POST` |
195+
| scoring.show_ranking_score_details | Was `showRankingScoreDetails` used in the aggregated event? If yes, `true`, otherwise `false` | `false` | `Documents Searched POST`, `Documents Searched GET`, `Documents Searched GET` |
194196

195197
----
196198

@@ -283,9 +285,11 @@ This property allows us to gather essential information to better understand on
283285
| formatting.max_attributes_to_crop | The maximum number of attributes to crop encountered among all requests in the aggregated event. | `100` |
284286
| formatting.crop_length | Does `cropLength` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
285287
| formatting.crop_marker | Does `cropMarker` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
286-
| formatting.show_matches_position | Does `showMatchesPosition` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
288+
| formatting.show_matches_position | Was `showMatchesPosition` used in the aggregated event? If yes, `true` otherwise `false` | `false` |
287289
| facets.avg_facets_number | The average number of facets among all the requests containing the `facets` parameter in the aggregated event. `"facets": []` equals to `0` while not sending `facets` does not influence the average in the aggregated event. | `10` |
288290
| matching_strategy.most_used_strategy | Most used word matching strategy among all search requests in the aggregated event. `last` / `all` | `last` |
291+
| scoring.show_ranking_score | Was `showRankingScore` used in the aggregated event? If yes, `true`, otherwise `false` | `false` |
292+
| scoring.show_ranking_score_details | Was `showRankingScoreDetails` used in the aggregated event? If yes, `true`, otherwise `false` | `false` |
289293

290294
---
291295

@@ -320,6 +324,8 @@ This property allows us to gather essential information to better understand on
320324
| formatting.show_matches_position | Does `showMatchesPosition` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
321325
| facets.avg_facets_number | The average number of facets among all the requests containing the `facets` parameter in the aggregated event. `"facets": []` equals to `0` while not sending `facets` does not influence the average in the aggregated event. | `10` |
322326
| matching_strategy.most_used_strategy | Most used word matching strategy among all search requests in the aggregated event. `last` / `all` | `last` |
327+
| scoring.show_ranking_score | Was `showRankingScore` used in the aggregated event? If yes, `true`, otherwise `false` | `false` |
328+
| scoring.show_ranking_score_details | Was `showRankingScoreDetails` used in the aggregated event? If yes, `true`, otherwise `false` | `false` |
323329

324330
---
325331

0 commit comments

Comments
 (0)