Skip to content

Commit

Permalink
fix(spec): better filters type
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Mar 18, 2022
1 parent cda79fb commit 9552944
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 62 deletions.
27 changes: 18 additions & 9 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ runs:
hashFiles(
'clients/algoliasearch-client-javascript/packages/client-search/**',
'!clients/algoliasearch-client-javascript/packages/client-search/dist',
'specs/bundled/search.yml'
'specs/bundled/search.yml',
'templates/javascript/**'
)}}
- name: Restore built JavaScript recommend client
Expand All @@ -221,7 +222,8 @@ runs:
hashFiles(
'clients/algoliasearch-client-javascript/packages/recommend/**',
'!clients/algoliasearch-client-javascript/packages/recommend/dist',
'specs/bundled/recommend.yml'
'specs/bundled/recommend.yml',
'templates/javascript/**'
)}}
- name: Restore built JavaScript query-suggestions client
Expand All @@ -234,7 +236,8 @@ runs:
hashFiles(
'clients/algoliasearch-client-javascript/packages/client-query-suggestions/**',
'!clients/algoliasearch-client-javascript/packages/client-query-suggestions/dist',
'specs/bundled/query-suggestions.yml'
'specs/bundled/query-suggestions.yml',
'templates/javascript/**'
)}}
- name: Restore built JavaScript personalization client
Expand All @@ -247,7 +250,8 @@ runs:
hashFiles(
'clients/algoliasearch-client-javascript/packages/client-personalization/**',
'!clients/algoliasearch-client-javascript/packages/client-personalization/dist',
'specs/bundled/personalization.yml'
'specs/bundled/personalization.yml',
'templates/javascript/**'
)}}
- name: Restore built JavaScript analytics client
Expand All @@ -260,7 +264,8 @@ runs:
hashFiles(
'clients/algoliasearch-client-javascript/packages/client-analytics/**',
'!clients/algoliasearch-client-javascript/packages/client-analytics/dist',
'specs/bundled/analytics.yml'
'specs/bundled/analytics.yml',
'templates/javascript/**'
)}}
- name: Restore built JavaScript abtesting client
Expand All @@ -273,7 +278,8 @@ runs:
hashFiles(
'clients/algoliasearch-client-javascript/packages/client-abtesting/**',
'!clients/algoliasearch-client-javascript/packages/client-abtesting/dist',
'specs/bundled/abtesting.yml'
'specs/bundled/abtesting.yml',
'templates/javascript/**'
)}}
- name: Restore built JavaScript insights client
Expand All @@ -286,7 +292,8 @@ runs:
hashFiles(
'clients/algoliasearch-client-javascript/packages/client-insights/**',
'!clients/algoliasearch-client-javascript/packages/client-insights/dist',
'specs/bundled/insights.yml'
'specs/bundled/insights.yml',
'templates/javascript/**'
)}}
- name: Restore built JavaScript sources client
Expand All @@ -299,7 +306,8 @@ runs:
hashFiles(
'clients/algoliasearch-client-javascript/packages/client-sources/**',
'!clients/algoliasearch-client-javascript/packages/client-sources/dist',
'specs/bundled/sources.yml'
'specs/bundled/sources.yml',
'templates/javascript/**'
)}}
- name: Restore built JavaScript predict client
Expand All @@ -312,7 +320,8 @@ runs:
hashFiles(
'clients/algoliasearch-client-javascript/packages/client-predict/**',
'!clients/algoliasearch-client-javascript/packages/client-predict/dist',
'specs/bundled/predict.yml'
'specs/bundled/predict.yml',
'templates/javascript/**'
)}}
# Restore Java clients: used during 'cts' or 'codegen'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ jobs:
hashFiles(
format('{0}/**', matrix.client.folder),
format('!{0}/dist', matrix.client.folder),
format('specs/bundled/{0}.yml', matrix.client.name)
format('specs/bundled/{0}.yml', matrix.client.name),
'templates/javascript/**'
)}}
- name: Generate '${{ matrix.client.name }}' client
Expand Down
46 changes: 27 additions & 19 deletions specs/common/schemas/SearchParams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,18 @@ baseSearchParams:
type: string
description: Filter the query with numeric, facet and/or tag filters.
default: ''
# There could be a pattern for this one (complicated one)
facetFilters:
type: array
items:
type: string
description: Filter hits by facet value.
default: []
$ref: '#/searchFilters'
optionalFilters:
type: array
items:
type: string
description: Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter.
default: []
$ref: '#/searchFilters'
numericFilters:
type: array
items:
type: string
description: Filter on numeric attributes.
default: []
$ref: '#/searchFilters'
tagFilters:
type: array
items:
type: string
description: Filter hits by tags.
default: []
$ref: '#/searchFilters'
sumOrFiltersScores:
type: boolean
description: Determines how to calculate the total score for filtering.
Expand Down Expand Up @@ -164,6 +151,9 @@ baseSearchParams:
type: boolean
description: Whether this search should use AI Re-Ranking.
default: true
reRankingApplyFilter:
description: When Dynamic Re-Ranking is enabled, only records that match these filters will be impacted by Dynamic Re-Ranking.
$ref: '#/searchFilters'

searchParamsString:
type: object
Expand Down Expand Up @@ -197,5 +187,23 @@ aroundRadius:
oneOf:
- type: integer
minimum: 1
- type: string
enum: [all]
- $ref: '#/aroundRadiusAll'

aroundRadiusAll:
type: string
enum: [all]

searchFilters:
oneOf:
- title: searchFiltersString
type: string
- title: searchFiltersArray
type: array
items:
type: string
- title: searchFiltersNestedArray
type: array
items:
type: array
items:
type: string
2 changes: 0 additions & 2 deletions specs/personalization/paths/personalizationStrategy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ post:
'404':
$ref: ../../common/responses/IndexNotFound.yml
get:
tags:
- personalization
operationId: getPersonalizationStrategy
description: The strategy contains information on the events and facets that impact user profiles and personalized search results.
summary: Get the current personalization strategy.
Expand Down
4 changes: 0 additions & 4 deletions specs/query-suggestions/paths/qsConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ put:
$ref: ../../common/responses/InternalError.yml

delete:
tags:
- query-suggestions
operationId: deleteConfig
description: >
Delete a configuration of a Query Suggestion's index.
Expand All @@ -42,8 +40,6 @@ delete:
$ref: ../../common/responses/InternalError.yml

get:
tags:
- query-suggestions
operationId: getConfig
description: Get the configuration of a single Query Suggestions index.
summary: Get the configuration of a single Query Suggestions index.
Expand Down
2 changes: 0 additions & 2 deletions specs/query-suggestions/paths/qsConfigs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ post:
$ref: ../../common/responses/InternalError.yml

get:
tags:
- query-suggestions
operationId: getAllConfigs
description: >
Get all the configurations of Query Suggestions.
Expand Down
61 changes: 44 additions & 17 deletions specs/search/common/schemas/Hit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,9 @@ rankingInfo:
type: integer
description: Precision used when computing the geo distance, in meters.
matchedGeoLocation:
type: object
additionalProperties:
type: object
additionalProperties: false
properties:
lat:
type: number
format: double
description: Latitude of the matched location.
lng:
type: number
format: double
description: Longitude of the matched location.
distance:
type: integer
description: Distance between the matched location and the search location (in meters).
$ref: '#/matchedGeoLocation'
personalization:
$ref: '#/personalization'
nbExactWords:
type: integer
description: Number of exactly matched words.
Expand All @@ -99,11 +86,51 @@ rankingInfo:
userScore:
type: integer
description: Custom ranking for the object, expressed as a single integer value.
word:
words:
type: integer
description: Number of matched words, including prefixes and typos.
promotedByReRanking:
type: boolean
description: Wether the record are promoted by the re-ranking strategy.
required:
- promoted
- nbTypos
- firstMatchedWord
- geoDistance
- nbExactWords
- words
- filters
- userScore

highlightedValue:
type: string
description: Markup text with occurrences highlighted.
example: <em>George</em> <em>Clo</em>oney

matchedGeoLocation:
type: object
properties:
lat:
type: number
format: double
description: Latitude of the matched location.
lng:
type: number
format: double
description: Longitude of the matched location.
distance:
type: integer
description: Distance between the matched location and the search location (in meters).

personalization:
type: object
properties:
filtersScore:
type: integer
description: The score of the filters.
rankingScore:
type: integer
description: The score of the ranking.
score:
type: integer
description: The score of the event.
2 changes: 0 additions & 2 deletions specs/search/paths/vault/vaultSources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ get:
$ref: ../../../common/responses/IndexNotFound.yml

put:
tags:
- search
operationId: replaceSources
description: Replace all allowed sources.
summary: Replace all allowed sources.
Expand Down
10 changes: 4 additions & 6 deletions templates/javascript/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { {{classname}} } from '{{filename}}';

{{! We handle types that depend on other interfaces }}
{{#interfaces.size}}
export type {{classname}} = {{#oneOf}}{{.}} {{^-last}}|{{/-last}} {{/oneOf}}{{#allOf}}{{.}} {{^-last}}&{{/-last}} {{/allOf}};
export type {{classname}} = {{#oneOf}}{{{.}}} {{^-last}}|{{/-last}} {{/oneOf}}{{#allOf}}{{{.}}} {{^-last}}&{{/-last}} {{/allOf}};
{{/interfaces.size}}

{{^interfaces}}
{{^interfaces.size}}
{{#description}}
/**
* {{{description}}}
Expand All @@ -30,6 +30,7 @@ export type {{classname}} = {
{{/vars}}
}
{{/isEnum}}
{{#hasEnums}}
{{#vars}}
{{#isEnum}}
Expand All @@ -38,13 +39,10 @@ export type {{classname}}{{nameInCamelCase}} = {{#allowableValues}}{{#enumVars}}
{{/isEnum}}
{{/vars}}
{{/hasEnums}}
{{/isEnum}}
{{#isEnum}}
export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}|{{/-last}}{{/enumVars}}{{/allowableValues}}
{{/isEnum}}
{{/interfaces}}
{{/interfaces.size}}
{{/model}}
{{/models}}

0 comments on commit 9552944

Please sign in to comment.