Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ public class AlgoliaSwiftGenerator extends Swift5ClientCodegen {
"supportedlanguage",
"tagfilters",
"taskstatus",
"timerange",
"typotolerance",
"typotoleranceenum",
"updatedatresponse",
"value"
);

Expand Down
12 changes: 9 additions & 3 deletions playground/javascript/node/recommend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const searchQuery = process.env.SEARCH_QUERY || 'test_query';
// Init client with appId and apiKey
const client = recommendClient(appId, apiKey);

async function testRecommend() {
async function testGetRecommendations() {
try {
const res = await client.getRecommendations({
requests: [
Expand All @@ -23,14 +23,20 @@ async function testRecommend() {
],
});

console.log(`[OK]`, res);
console.log('[OK] GetRecommendations', res);
} catch (e) {
if (e instanceof ApiError) {
return console.log(`[${e.status}] ${e.message}`, e.stackTrace);
}

console.log('[ERROR]', e);
console.log('[ERROR] GetRecommendations', e);
}
}



async function testRecommend() {
await testGetRecommendations();
}

testRecommend();
14 changes: 14 additions & 0 deletions specs/common/schemas/Rule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,17 @@ context:
For example, if `context: mobile`, the rule is only triggered when the search request has a matching `ruleContexts: mobile`.
A rule context must only contain alphanumeric characters.
example: mobile

timeRange:
type: object
additionalProperties: false
properties:
from:
type: integer
description: When the rule should start to be active, in Unix epoch time.
until:
type: integer
description: When the rule should stop to be active, in Unix epoch time.
required:
- from
- until
21 changes: 20 additions & 1 deletion specs/recommend/common/schemas/RecommendRule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ RecommendRule:
description:
type: string
description: Description of the rule's purpose. This can be helpful for display in the Algolia dashboard.
example: 'Display a promotional banner'
example: 'Boost on-sale items'
enabled:
type: boolean
default: true
description: Indicates whether to enable the rule. If it isn't enabled, it isn't applied at query time.
validity:
type: array
description: Time periods when the rule is active.
items:
$ref: '#/timeRange'

Condition:
type: object
Expand Down Expand Up @@ -118,3 +123,17 @@ AutoFacetFilter:
Whether the filter is negative.
If true, recommendations must not have the same value for the `facet` attribute.
If false, recommendations must have the same value for the `facet` attribute.

timeRange:
type: object
additionalProperties: false
properties:
from:
type: integer
description: When the rule should start to be active, in Unix epoch time.
until:
type: integer
description: When the rule should stop to be active, in Unix epoch time.
required:
- from
- until
40 changes: 40 additions & 0 deletions specs/recommend/paths/batchRecommendRules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
post:
tags:
- rules
operationId: batchRecommendRules
x-use-read-transporter: false
x-cacheable: false
x-acl:
- editSettings
summary: Create or update a batch of Recommend Rules
description: |
Create or update a batch of Recommend Rules

Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same `objectID` already exists.
You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules.

Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following:
- Conditions `pattern` and `anchoring` are unavailable.
- Condition `filters` triggers if the source item matches the specified filters.
- Condition `filters` accepts numeric filters.
- Consequence `params` only covers filtering parameters.
- Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to match the data source item's attributes instead).
parameters:
- $ref: '../../common/parameters.yml#/IndexName'
- $ref: '../common/parameters.yml#/Models'
requestBody:
content:
application/json:
schema:
title: rules
type: array
description: Recommend rules.
additionalProperties: false
items:
$ref: '../common/schemas/RecommendRule.yml#/RecommendRule'

responses:
'200':
$ref: '../../common/responses/UpdatedAt.yml'
'400':
$ref: '../../common/responses/BadRequest.yml'
3 changes: 3 additions & 0 deletions specs/recommend/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ paths:

/1/indexes/{indexName}/{model}/recommend/rules/search:
$ref: 'paths/searchRecommendRules.yml'

/1/indexes/{indexName}/{model}/recommend/rules/batch:
$ref: 'paths/batchRecommendRules.yml'

# ###############
# ### Helpers ###
Expand Down
32 changes: 18 additions & 14 deletions templates/javascript/clients/algoliasearch/builds/models.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import type {
AroundRadiusAll,
AutomaticFacetFilter,
AutomaticFacetFilters,
BaseSearchParams,
BaseIndexSettings,
BaseSearchParams,
BaseSearchParamsWithoutQuery,
BaseSearchResponse,
BooleanString,
Expand Down Expand Up @@ -43,8 +43,8 @@ import type {
HighlightResultOption,
IgnorePlurals,
IndexSettingsAsSearchParams,
MatchLevel,
MatchedGeoLocation,
MatchLevel,
Mode,
NumericFilters,
OptionalFilters,
Expand All @@ -56,14 +56,14 @@ import type {
QueryType,
Range,
RankingInfo,
ReRankingApplyFilter,
Redirect,
RedirectRuleIndexMetadata,
RedirectRuleIndexData,
RedirectRuleIndexMetadata,
RedirectURL,
RemoveStopWords,
RemoveWordsIfNoResults,
RenderingContent,
ReRankingApplyFilter,
SearchPagination,
SearchParams,
SearchParamsObject,
Expand All @@ -75,8 +75,10 @@ import type {
SupportedLanguage,
TagFilters,
TaskStatus,
TimeRange,
TypoTolerance,
TypoToleranceEnum,
UpdatedAtResponse,
Value,
} from '@algolia/client-search';
import { apiClientVersion } from '@algolia/client-search';
Expand All @@ -91,16 +93,19 @@ export * from '@algolia/client-analytics';
export * from '@algolia/client-abtesting';

export {
AbTestingRegion,
AdvancedSyntaxFeatures,
AlternativesAsExact,
AnalyticsRegion,
Anchoring,
apiClientVersion,
AroundPrecision,
AroundRadius,
AroundRadiusAll,
AutomaticFacetFilter,
AutomaticFacetFilters,
BaseSearchParams,
BaseIndexSettings,
BaseSearchParams,
BaseSearchParamsWithoutQuery,
BaseSearchResponse,
BooleanString,
Expand Down Expand Up @@ -129,8 +134,8 @@ export {
HighlightResultOption,
IgnorePlurals,
IndexSettingsAsSearchParams,
MatchLevel,
MatchedGeoLocation,
MatchLevel,
Mode,
NumericFilters,
OptionalFilters,
Expand All @@ -142,32 +147,31 @@ export {
QueryType,
Range,
RankingInfo,
ReRankingApplyFilter,
Redirect,
RedirectRuleIndexMetadata,
RedirectRuleIndexData,
RedirectRuleIndexMetadata,
RedirectURL,
Region,
RemoveStopWords,
RemoveWordsIfNoResults,
RenderingContent,
ReRankingApplyFilter,
SearchPagination,
SearchParams,
SearchParamsObject,
SearchParamsQuery,
SemanticSearch,
SearchPagination,
SnippetResult,
SnippetResultOption,
SortRemainingBy,
SupportedLanguage,
TagFilters,
TaskStatus,
TimeRange,
TypoTolerance,
TypoToleranceEnum,
UpdatedAtResponse,
Value,
AnalyticsRegion,
AbTestingRegion,
Region,
apiClientVersion,
};

/**
Expand All @@ -190,4 +194,4 @@ export type InitClientRegion<TRegion> = Partial<{
* Available regions of the initialized client.
*/
region: TRegion;
}>;
}>;
14 changes: 14 additions & 0 deletions tests/CTS/requests/recommend/batchRecommendRules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"testName": "batch recommend rules",
"parameters": {
"indexName": "indexName",
"model": "related-products"
},
"request": {
"path": "/1/indexes/indexName/related-products/recommend/rules/batch",
"method": "POST",
"body": {}
}
}
]
Loading