Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/algoliasearch-client-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"files": [
{
"path": "packages/algoliasearch/dist/algoliasearch.umd.js",
"maxSize": "22KB"
"maxSize": "22.25KB"
},
{
"path": "packages/algoliasearch/dist/lite/builds/browser.umd.js",
Expand Down
16 changes: 16 additions & 0 deletions specs/abtesting-v3/common/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ ID:
schema:
$ref: '#/abTestID'

Methods:
in: query
name: methods
description: |
Statistical analysis results to include, as a comma-separated list.
When omitted, each test uses its configured method, or `frequentist` if no method is configured.
Request both methods to include both sets of available results. This doesn't change the test configuration or compute missing results.
Duplicate values aren't allowed.
style: form
explode: false
schema:
type: array
minItems: 1
Comment thread
stevenMevans marked this conversation as resolved.
items:
$ref: 'schemas/ABTest.yml#/AnalysisMethod'
Comment thread
stevenMevans marked this conversation as resolved.

# misc
index:
type: string
Expand Down
29 changes: 28 additions & 1 deletion specs/abtesting-v3/common/schemas/ABTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ ABTestConfiguration:
$ref: '#/MetricsFilters'
errorCorrection:
$ref: '#/ErrorCorrectionType'
method:
$ref: '#/AnalysisMethod'
primaryMetric:
$ref: '#/PrimaryMetric'
Comment thread
stevenMevans marked this conversation as resolved.

MinimumDetectableEffect:
type: object
description: Configuration for the smallest difference between test variants you want to detect.
description: Configuration for the smallest difference between test variants you want to detect, used to estimate the required sample size.
properties:
size:
type: number
Expand All @@ -117,6 +121,20 @@ EffectMetric:
- purchaseRate
- noResultsRate

PrimaryMetric:
type: string
description: |
Primary metric for Bayesian analysis. Required when `method` is `bayesian`.
If the request includes a non-empty `metrics` list, this metric must be in that list.
Revenue per search requires access to revenue analytics.
example: conversion_rate
enum:
- add_to_cart_rate
- click_through_rate
- conversion_rate
- purchase_rate
- revenue_per_search

MetricsFilter:
type: object
additionalProperties: false
Expand Down Expand Up @@ -154,3 +172,12 @@ ErrorCorrectionType:
enum:
- bonferroni
- benjamini-hochberg

AnalysisMethod:
type: string
description: |
A/B test statistical analysis method.
When omitted, the test is treated as `frequentist`. The server doesn't write a default value back to the configuration.
enum:
- bayesian
- frequentist
Comment thread
stevenMevans marked this conversation as resolved.
2 changes: 1 addition & 1 deletion specs/abtesting-v3/common/schemas/ABTestSettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FeatureSettings:
name:
type: string
description: Name of the feature the settings belong to.
example: 'reranking'
example: 'drr'
settings:
description: Feature settings payload. The shape depends on the feature.
required:
Expand Down
3 changes: 3 additions & 0 deletions specs/abtesting-v3/common/schemas/Timeseries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ MetricName:
- user_count
- tracked_user_count
- no_result_count
- tracked_no_result_count
- add_to_cart_count
- purchase_count
- clicked_search_count
Expand All @@ -59,3 +60,5 @@ MetricName:
- purchase_rate
- average_click_position
- revenue
- revenue_per_search
- average_order_value
74 changes: 72 additions & 2 deletions specs/abtesting-v3/common/schemas/Variant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ metricResult:
properties:
name:
type: string
description: Metric name. Revenue per search results use `revenue_per_search`.
updatedAt:
type: string
description: Date and time when the metric was last updated, in RFC 3339 format.
value:
type: number
format: double
description: Metric value. For `revenue_per_search`, this is the winsorized mean revenue per search in the specified currency.
valueCIHigh:
type: number
format: double
Expand All @@ -83,7 +85,7 @@ metricResult:
Omitted when no p-value is available for this metric.
dimension:
type: string
description: Dimension defined during test creation.
description: Dimension defined during test creation. For revenue metrics, including `revenue_per_search`, this is the currency.
metadata:
$ref: '#/metricMetadata'
criticalValue:
Expand All @@ -97,6 +99,8 @@ metricResult:
type: boolean
description: |
Whether the pValue is significant or not based on the critical value and the error correction algorithm used.
bayesian:
$ref: '#/bayesianMetricResult'
required:
- name
- updatedAt
Expand All @@ -109,6 +113,7 @@ metricResult:
updatedAt: 2025-05-15T17:52:15.644906Z
value: 0.20869847452125934
pValue: 0.004
bayesian: {'probabilityToBeBetter': 0.991, 'evidence': {'status': 'enough'}}
- name: revenue
dimension: USD
updatedAt: 2025-05-15T17:52:15.644906Z
Expand All @@ -121,6 +126,71 @@ metricResult:
value: 999.66
pValue: 0.04
metadata: {'winsorizedValue': 888.8}
- name: revenue_per_search
dimension: USD
updatedAt: 2025-05-15T17:52:15.644906Z
value: 12.45
metadata: {'mean': 12.45}
Comment thread
Copilot marked this conversation as resolved.
bayesian:
probabilityToBeBetter: 0.991
relativeEffectCILow: 0.04
relativeEffectCIHigh: 0.39
evidence: {'status': 'unavailable'}

bayesianMetricResult:
type: object
description: |
Bayesian inference results for this variant metric.
Omitted when Bayesian results aren't requested or no Bayesian result is available for this metric.
Individual inference fields can be omitted when their values aren't available.
properties:
probabilityToBeBetter:
type: number
format: double
description: Probability that this variant is better than the control.
example: 0.991
relativeEffectCILow:
type: number
format: double
description: Lower bound of the 95% credible interval for the relative effect (variant/control minus 1).
example: 0.04
relativeEffectCIHigh:
type: number
format: double
description: Upper bound of the 95% credible interval for the relative effect (variant/control minus 1).
example: 0.39
evidence:
$ref: '#/metricEvidence'

metricEvidence:
type: object
description: |
Evidence status for this variant metric's comparison with the control.
Only present when the API has an evidence status for the comparison. Omitted when evidence isn't applicable or no status exists.
properties:
status:
$ref: '#/evidenceStatus'
required:
- status

evidenceStatus:
type: string
description: |
Whether this variant metric's result is trustworthy yet.
This doesn't mean the A/B test has ended, and it doesn't declare a winning variant.

- `enough`. Enough evidence has accumulated to trust this metric's result for this variant.
- `not_enough`. Evidence was computed but hasn't reached the threshold yet.
- `collecting`. Evidence is still accumulating, so it's too early to report a verdict.
- `no_data`. No usable data for this variant metric, and none is expected for it.
- `unavailable`. Evidence can't be computed for this variant metric's comparison.
example: not_enough
enum:
- enough
- not_enough
- collecting
- no_data
- unavailable

variantMetadata:
type: object
Expand All @@ -137,7 +207,7 @@ metricMetadata:
type: number
format: double
description: |
Only present in case the metric is 'revenue'.
Only present for `revenue` metrics.
It is the amount exceeding the 95th percentile of global revenue transactions involved in the AB Test. This amount is not considered when calculating statistical significance.
It is tied to a per revenue-currency pair contrary to other
global filter effects (such as outliers and empty search count).
Expand Down
3 changes: 3 additions & 0 deletions specs/abtesting-v3/paths/abtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ get:
description: Retrieves the details for an A/B test by its ID.
parameters:
- $ref: '../common/parameters.yml#/ID'
- $ref: '../common/parameters.yml#/Methods'
responses:
'200':
description: OK
Expand All @@ -30,6 +31,8 @@ get:
$ref: '../../common/responses/MethodNotAllowed.yml'
'404':
$ref: '../../common/responses/IndexNotFound.yml'
'422':
$ref: '../../common/responses/UnprocessableEntity.yml'

delete:
tags:
Expand Down
5 changes: 5 additions & 0 deletions specs/abtesting-v3/paths/abtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ post:
$ref: '../../common/responses/MethodNotAllowed.yml'
'404':
$ref: '../../common/responses/IndexNotFound.yml'
'422':
$ref: '../../common/responses/UnprocessableEntity.yml'

get:
tags:
Expand Down Expand Up @@ -106,6 +108,7 @@ get:
example: desc
schema:
$ref: '../common/parameters.yml#/direction'
- $ref: '../common/parameters.yml#/Methods'
responses:
'200':
description: OK
Expand Down Expand Up @@ -145,3 +148,5 @@ get:
$ref: '../../common/responses/MethodNotAllowed.yml'
'404':
$ref: '../../common/responses/IndexNotFound.yml'
'422':
$ref: '../../common/responses/UnprocessableEntity.yml'
6 changes: 5 additions & 1 deletion specs/abtesting-v3/paths/applyVariantSettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ post:
'403':
$ref: '../../common/responses/MethodNotAllowed.yml'
'404':
$ref: '../../common/responses/IndexNotFound.yml'
description: A/B test, variant, or index not found.
content:
application/json:
schema:
$ref: '../../common/schemas/ErrorBase.yml'
'422':
$ref: '../../common/responses/UnprocessableEntity.yml'
1 change: 1 addition & 0 deletions specs/abtesting-v3/paths/timeseries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ get:
type: array
items:
$ref: '../common/schemas/Timeseries.yml#/MetricName'
- $ref: '../common/parameters.yml#/Methods'
responses:
'200':
description: OK
Expand Down
6 changes: 5 additions & 1 deletion specs/abtesting-v3/paths/variantSettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ post:
'403':
$ref: '../../common/responses/MethodNotAllowed.yml'
'404':
$ref: '../../common/responses/IndexNotFound.yml'
description: A/B test, variant, or index not found.
content:
application/json:
schema:
$ref: '../../common/schemas/ErrorBase.yml'
'409':
$ref: '../../common/responses/Conflict.yml'
'422':
Expand Down
45 changes: 45 additions & 0 deletions tests/CTS/requests/abtesting-v3/addABTests.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,50 @@
]
}
}
},
{
"testName": "addABTests with Bayesian configuration",
"parameters": {
"endAt": "2022-12-31T00:00:00.000Z",
"name": "myABTest",
"metrics": [{"name": "conversionRate"}],
"variants": [
{
"index": "AB_TEST_1",
"trafficPercentage": 30
},
{
"index": "AB_TEST_2",
"trafficPercentage": 50
}
],
"configuration": {
"method": "bayesian",
"primaryMetric": "conversion_rate"
}
},
"request": {
"path": "/3/abtests",
"method": "POST",
"body": {
"endAt": "2022-12-31T00:00:00.000Z",
"name": "myABTest",
"metrics": [{"name": "conversionRate"}],
"variants": [
{
"index": "AB_TEST_1",
"trafficPercentage": 30
},
{
"index": "AB_TEST_2",
"trafficPercentage": 50
}
],
"configuration": {
"method": "bayesian",
"primaryMetric": "conversion_rate"
}
}
}
}
]
9 changes: 9 additions & 0 deletions tests/CTS/requests/abtesting-v3/getABTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@
"path": "/3/abtests/42",
"method": "GET"
}
},
{
"testName": "getABTest with both inference methods",
"parameters": { "id": 42, "methods": ["frequentist", "bayesian"] },
"request": {
"path": "/3/abtests/42",
"method": "GET",
"queryParameters": { "methods": "frequentist%2Cbayesian" }
}
}
]
20 changes: 20 additions & 0 deletions tests/CTS/requests/abtesting-v3/getTimeseries.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,25 @@
"path": "/3/abtests/42/timeseries",
"method": "GET"
}
},
{
"testName": "getTimeseries with Bayesian revenue per search",
"parameters": {
"id": 42,
"startDate": "1999-09-19",
"endDate": "2001-01-01",
"metric": ["revenue_per_search"],
"methods": ["bayesian"]
},
"request": {
"path": "/3/abtests/42/timeseries",
"method": "GET",
"queryParameters": {
"startDate": "1999-09-19",
"endDate": "2001-01-01",
"metric": "revenue_per_search",
"methods": "bayesian"
}
}
}
]
Loading
Loading