query rules

This commit is contained in:
Haroen Viaene
2017-11-03 13:30:40 +01:00
parent 17f7b08f2d
commit cf50d0507e

View File

@@ -545,6 +545,65 @@ declare namespace algoliasearch {
options: SearchSynonymOptions,
cb: (err: Error, res: any) => void
): void;
/**
* Save a rule object
* @param rule
* @param options
* @param cb(err, res)
* https://github.com/algolia/algoliasearch-client-js#save-rule---saverule
*/
saveRule(
rule: AlgoliaRule,
options: RuleOption,
cb: (err: Error, res: any) => void
): void;
/**
* Save a rule object
* @param rules
* @param options
* @param cb(err, res)
*/
batchRules(
rules: AlgoliaRule[],
options: RuleOption,
cb: (err: Error, res: any) => void
): void;
/**
* Delete a specific rule
* @param identifier
* @param options
* @param cb(err, res)
* https://github.com/algolia/algoliasearch-client-js#batch-rules---batchrules
*/
deleteRule(
identifier: string,
options: RuleOption,
cb: (err: Error, res: any) => void
): void;
/**
* Clear all rules of an index
* @param options
* @param cb(err, res)
* https://github.com/algolia/algoliasearch-client-js#clear-all-rules---clearrules
*/
clearRules(options: RuleOption, cb: (err: Error, res: any) => void): void;
/**
* Get a specific rule
* @param identifier
* @param cb(err, res)
* https://github.com/algolia/algoliasearch-client-js#get-rule---getrule
*/
getRule(identifier: string, cb: (err: Error, res: any) => void): void;
/**
* Search a rules
* @param options
* @param cb(err, res)
* https://github.com/algolia/algoliasearch-client-js#search-rules---searchrules
*/
searchRules(
options: SearchRuleOptions,
cb: (err: Error, res: any) => void
): void;
/**
* List index user keys
* @param cb(err, res)
@@ -858,6 +917,50 @@ declare namespace algoliasearch {
* https://github.com/algolia/algoliasearch-client-js#search-synonyms---searchsynonyms
*/
searchSynonyms(options: SearchSynonymOptions): Promise<any>;
/**
* Save a rule object
* @param rule
* @param options
* return {Promise}
* https://github.com/algolia/algoliasearch-client-js#save-rule---saverule
*/
saveRule(rule: AlgoliaRule, options: RuleOption): Promise<any>;
/**
* Save a rule object
* @param rules
* @param options
* return {Promise}
*/
batchRules(rules: AlgoliaRule[], options: RuleOption): Promise<any>;
/**
* Delete a specific rule
* @param identifier
* @param options
* return {Promise}
* https://github.com/algolia/algoliasearch-client-js#batch-rules---batchrules
*/
deleteRule(identifier: string, options: RuleOption): Promise<any>;
/**
* Clear all query rules of an index
* @param options
* return {Promise}
* https://github.com/algolia/algoliasearch-client-js#clear-all-rules---clearrules
*/
clearRules(options: RuleOption): Promise<any>;
/**
* Get a specific query rule
* @param identifier
* return {Promise}
* https://github.com/algolia/algoliasearch-client-js#get-rule---getrule
*/
getRule(identifier: string): Promise<any>;
/**
* Search for query rules
* @param options
* return {Promise}
* https://github.com/algolia/algoliasearch-client-js#search-rules---searchrules
*/
searchRules(options: SearchRuleOptions): Promise<any>;
/**
* List index user keys
* return {Promise}
@@ -1036,8 +1139,8 @@ Interface describing options available for gettings the logs
description?: string;
}
/**
* Describes option used when making operation on synonyms
*/
* Describes option used when making operation on synonyms
*/
interface SynonymOption {
/**
* You can forward all settings updates to the replicas of an index
@@ -1051,8 +1154,8 @@ Interface describing options available for gettings the logs
replaceExistingSynonyms?: boolean;
}
/**
* Describes options used when searching for synonyms
*/
* Describes options used when searching for synonyms
*/
interface SearchSynonymOptions {
/**
* The actual search query to find synonyms
@@ -1061,7 +1164,7 @@ Interface describing options available for gettings the logs
query?: string;
/**
* The page to fetch when browsing through several pages of results
* default: 100
* default: 0
* https://github.com/algolia/algoliasearch-client-js#search-synonyms---searchsynonyms
*/
page?: number;
@@ -1078,6 +1181,49 @@ Interface describing options available for gettings the logs
*/
hitsPerPage?: number;
}
/**
* Describes option used when making operation on query rules
*/
interface RuleOption {
/**
* You can forward all settings updates to the replicas of an index
* https://github.com/algolia/algoliasearch-client-js#replica-settings
*/
forwardToReplicas?: boolean;
/**
* Replace all existing query rules on the index with the content of the batch
*/
clearExistingRules?: boolean;
}
/**
* Describes options used when searching for query rules
*/
interface SearchRuleOptions {
/**
* The actual search query to find synonyms
*/
query?: string;
/**
* When specified, restricts matches to rules with a specific anchoring type.
* When omitted, all anchoring types may match.
*/
anchoring?: string;
/**
* When specified, restricts matches to contextual rules with a specific context (exact match).
* When omitted, any generic or contextual rule (with any context) may match.
*/
context?: string;
/**
* Requested page (zero-based)
* default: 0
*/
page?: number;
/**
* Number of hits per page
* default: 20
*/
hitsPerPage?: number;
}
interface AlgoliaBrowseResponse {
cursor?: string;
hits: any[];
@@ -1106,8 +1252,94 @@ Interface describing options available for gettings the logs
synonyms: string[];
}
/**
* Describes the options used when generating new api keys
*/
* Describes a query rule object
*/
interface AlgoliaRule {
/**
* ObjectID of the synonym
* https://github.com/algolia/algoliasearch-client-js#save-synonym---savesynonym
*/
objectID: string;
/**
* Condition of the rule
*/
condition: {
/**
* Query pattern
* syntax: https://www.algolia.com/doc/rest-api/query-rules/?language=php#query-pattern-syntax
*/
pattern: string;
/**
* Whether the pattern must match the beginning or the end of the query string, or both, or none.
*/
anchoring: 'is' | 'startsWith' | 'endsWith' | 'contains';
/**
* Rule context (format: [A-Za-z0-9_-]+).
* When specified, the rule is contextual and applies only when the same context is specified
* at query time (using the ruleContexts parameter).
* When absent, the rule is generic and always applies
* (provided that its other conditions are met, of course).
*/
context?: string;
};
/**
* Consequence of the rule. At least one of the following must be used:
*/
consequence: {
params?: {
/**
* When a string, it replaces the entire query string.
* When an object, describes incremental edits to be made to the query string.
*/
query?:
| string
| {
/**
* Tokens (literals or placeholders) from the query pattern
* that should be removed from the query string.
*/
remove: string[];
};
/**
* Names of facets to which automatic filtering must be applied;
* they must match the facet name of a facet value placeholder in the query pattern.
*/
automaticFacetFilters?: string[];
/**
* Same as automaticFacetFilters, but for optionalFacetFilters.
* The same syntax as query parameters can be used to specify a score: facetName<score=1>.
*/
automaticOptionalFacetFilters?: string[];
};
/**
* Objects to promote as hits. Each object must contain the following fields
*/
promote?: {
/**
* Unique identifier of the object to promote
*/
objectID: string;
/**
* Promoted rank for the object (zero-based)
*/
position: number;
}[];
/**
* Custom JSON object that will be appended to the userData array in the response.
* This object is not interpreted by the API. It is limited to 1kB of minified JSON.
*/
userData?: {};
};
/**
* This field is intended for rule management purposes,
* in particular to ease searching for rules and presenting them to human readers.
* It is not interpreted by the API.
*/
description?: string;
}
/**
* Describes the options used when generating new api keys
*/
interface AlgoliaSecuredApiOptions {
/**
* Filter the query with numeric, facet or/and tag filters