openapi: 3.0.2
info:
title: Search API
summary: >-
The Algolia Search API lets you search, configure, and manage your indices
and records
description: >
## Client libraries
Use Algolia's API clients and libraries to reliably integrate Algolia's APIs
with your apps.
The official API clients are covered by Algolia's [Service Level
Agreement](https://www.algolia.com/policies/sla).
For more information, see [Algolia's
ecosystem](https://www.algolia.com/doc/libraries).
## Base URLs
Base URLs for the Search API:
- `https://{APPLICATION_ID}.algolia.net`
- `https://{APPLICATION_ID}-dsn.algolia.net`.
If your subscription includes a [Distributed Search Network](https://dashboard.algolia.com/infra),
this ensures that requests are sent to servers closest to users.
Both URLs provide high availability by distributing requests with load
balancing.
**All requests must use HTTPS.**
## Retry strategy
To guarantee high availability, implement a retry strategy for all API
requests using the URLs of your servers as fallbacks:
- `https://{APPLICATION_ID}-1.algolianet.com`
- `https://{APPLICATION_ID}-2.algolianet.com`
- `https://{APPLICATION_ID}-3.algolianet.com`
These URLs use a different DNS provider than the primary URLs.
Randomize this list to ensure an even load across the three servers.
All Algolia API clients implement this retry strategy.
## Authentication
Add these headers to authenticate requests:
- `x-algolia-application-id`. Your Algolia application ID.
- `x-algolia-api-key`. An API key with the necessary permissions to make the
request.
The required access control list (ACL) to make a request is listed in each endpoint's reference.
You can find your application ID and API key in the [Algolia
dashboard](https://dashboard.algolia.com/account/api-keys).
## Request format
Depending on the endpoint, request bodies are either JSON objects or arrays
of JSON objects.
## Parameters
Parameters are passed as query parameters for GET and DELETE requests,
and in the request body for POST and PUT requests.
Query parameters must be
[URL-encoded](https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding).
Non-ASCII characters must be UTF-8 encoded.
Plus characters (`+`) are interpreted as spaces.
Arrays as query parameters must be one of:
- A comma-separated string: `attributesToRetrieve=title,description`
- A URL-encoded JSON array:
`attributesToRetrieve=%5B%22title%22,%22description%22%D`
## Response status and errors
The Search API returns JSON responses.
Since JSON doesn't guarantee any specific ordering, don't rely on the order
of attributes in the API response.
Successful responses return `2xx` statuses. Client errors return `4xx`
statuses. Server errors return `5xx` statuses.
Error responses have a `message` property with more information.
## Request identifiers
Every response includes a `Correlation-ID` header that identifies the
request in Algolia's logs.
When contacting the Algolia support team about a specific request, include
this identifier in your ticket.
To tag requests with your own identifier, send a `Request-ID` header with
exactly 11 alphanumeric characters.
Clusters that support it embed the identifier at the end of the
`Correlation-ID`,
so all attempts of a retried operation can be found by searching for those
characters.
Headers that don't match the expected format are ignored.
Don't use the `Correlation-ID` as a unique key: retried requests may receive
the same identifier.
## Version
The current version of the Search API is version 1, indicated by the `/1/`
in each endpoint's URL.
version: 1.0.0
servers:
- url: https://{appId}.algolia.net
variables:
appId:
default: ALGOLIA_APPLICATION_ID
- url: https://{appId}-1.algolianet.com
variables:
appId:
default: ALGOLIA_APPLICATION_ID
- url: https://{appId}-2.algolianet.com
variables:
appId:
default: ALGOLIA_APPLICATION_ID
- url: https://{appId}-3.algolianet.com
variables:
appId:
default: ALGOLIA_APPLICATION_ID
- url: https://{appId}-dsn.algolia.net
variables:
appId:
default: ALGOLIA_APPLICATION_ID
security:
- appId: []
apiKey: []
tags:
- name: Advanced
description: Query your logs.
- name: Api Keys
x-displayName: API keys
description: >
Manage your API keys.
API requests must be authenticated with an API key.
API keys can have permissions (access control lists, ACL) and
restrictions.
externalDocs:
url: https://www.algolia.com/doc/guides/security/api-keys
description: API keys.
- name: Clusters
description: |
Multi-cluster operations.
Multi-cluster operations are **deprecated**.
If you have issues with your Algolia infrastructure
due to large volumes of data, contact the Algolia support team.
- name: Dictionaries
description: >
Manage your dictionaries.
Customize language-specific settings, such as stop words, plurals, or word
segmentation.
Dictionaries are application-wide.
externalDocs:
url: >-
https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp
description: Natural languages.
- name: Indices
description: >
Manage your indices and index settings.
Indices are copies of your data that are stored on Algolia's servers.
They're optimal data structures for fast search and are made up of records
and settings.
externalDocs:
url: >-
https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices
description: Manage your indices.
- name: Records
description: >
Add, update, and delete records from your indices.
Records are individual items in your index.
When they match a search query, they're returned as search results, in the
order determined by your ranking.
Records are schemaless JSON objects.
When adding or updating many records, check the [indexing rate
limits](https://support.algolia.com/hc/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
externalDocs:
url: >-
https://www.algolia.com/doc/guides/sending-and-managing-data/prepare-your-data
description: Prepare your records.
- name: Rules
description: >
Create, update, delete, and search for rules.
Rules are _if-then_ statements that you can use to curate search results.
Rules have _conditions_ that can trigger _consequences_.
Consequences are changes to the search results, such as changing the order
of search results or boosting a facet.
This can be useful for tuning specific queries or for merchandising.
externalDocs:
url: https://www.algolia.com/doc/guides/managing-results/rules/rules-overview
description: Index Rules.
- name: Search
description: Search one or more indices for matching records or facet values.
- name: Synonyms
description: |
Create, update, delete, and search for synonyms.
Synonyms are terms that the search engine should consider equal.
externalDocs:
url: >-
https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms
description: Synonyms.
- name: Vaults
description: >-
Algolia Vault lets you restrict access to your clusters to specific IP
addresses and provides disk-level encryption at rest.
externalDocs:
url: https://www.algolia.com/doc/guides/security/algolia-vault
description: Algolia Vault.
- name: _model_index_settings
x-displayName: Index settings
description: |
.
paths:
/{path}:
get:
operationId: customGet
summary: Send requests to the Algolia REST API
description: This method lets you send requests to the Algolia REST API.
parameters:
- $ref: '#/components/parameters/PathInPath'
- $ref: '#/components/parameters/Parameters'
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.CustomGetAsync("test/minimal");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.customGet(
path: "test/minimal",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.CustomGet(client.NewApiCustomGetRequest(
"test/minimal"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
Object response = client.customGet("test/minimal");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.customGet({ path: 'test/minimal' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.customGet(path = "test/minimal")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->customGet(
'test/minimal',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.custom_get(
path="test/minimal",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.custom_get("test/minimal")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.customGet[JObject](
path = "test/minimal"
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.customGet(path: "test/minimal")
// print the response
print(response)
post:
operationId: customPost
requestBody:
description: Parameters to send with the custom request.
content:
application/json:
schema:
type: object
summary: Send requests to the Algolia REST API
description: This method lets you send requests to the Algolia REST API.
parameters:
- $ref: '#/components/parameters/PathInPath'
- $ref: '#/components/parameters/Parameters'
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.CustomPostAsync("test/minimal");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.customPost(
path: "test/minimal",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.CustomPost(client.NewApiCustomPostRequest(
"test/minimal"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
Object response = client.customPost("test/minimal");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.customPost({ path: 'test/minimal' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.customPost(path = "test/minimal")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->customPost(
'test/minimal',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.custom_post(
path="test/minimal",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.custom_post("test/minimal")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.customPost[JObject](
path = "test/minimal"
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.customPost(path: "test/minimal")
// print the response
print(response)
put:
operationId: customPut
requestBody:
description: Parameters to send with the custom request.
content:
application/json:
schema:
type: object
summary: Send requests to the Algolia REST API
description: This method lets you send requests to the Algolia REST API.
parameters:
- $ref: '#/components/parameters/PathInPath'
- $ref: '#/components/parameters/Parameters'
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.CustomPutAsync("test/minimal");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.customPut(
path: "test/minimal",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.CustomPut(client.NewApiCustomPutRequest(
"test/minimal"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
Object response = client.customPut("test/minimal");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.customPut({ path: 'test/minimal' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.customPut(path = "test/minimal")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->customPut(
'test/minimal',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.custom_put(
path="test/minimal",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.custom_put("test/minimal")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.customPut[JObject](
path = "test/minimal"
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.customPut(path: "test/minimal")
// print the response
print(response)
delete:
operationId: customDelete
summary: Send requests to the Algolia REST API
description: This method lets you send requests to the Algolia REST API.
parameters:
- $ref: '#/components/parameters/PathInPath'
- $ref: '#/components/parameters/Parameters'
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.CustomDeleteAsync("test/minimal");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.customDelete(
path: "test/minimal",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err :=
client.CustomDelete(client.NewApiCustomDeleteRequest(
"test/minimal"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
Object response = client.customDelete("test/minimal");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.customDelete({ path: 'test/minimal'
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.customDelete(path = "test/minimal")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->customDelete(
'test/minimal',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.custom_delete(
path="test/minimal",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.custom_delete("test/minimal")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.customDelete[JObject](
path = "test/minimal"
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.customDelete(path: "test/minimal")
// print the response
print(response)
/1/indexes/{indexName}/query:
post:
tags:
- Search
operationId: searchSingleIndex
x-mcp-tool: true
x-use-read-transporter: true
x-cacheable: true
x-acl:
- search
summary: Search an index
description: >
Searches a single index and returns matching search results as hits.
This method lets you retrieve up to 1,000 hits.
If you need more, use the [`browse`
operation](https://www.algolia.com/doc/rest-api/search/browse) or
increase the `paginatedLimitedTo` index setting.
parameters:
- $ref: '#/components/parameters/IndexName'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/searchParams'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/searchResponse'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await
client.SearchSingleIndexAsync("");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.searchSingleIndex(
indexName: "",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err :=
client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
""))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
SearchResponse response =
client.searchSingleIndex("", Hit.class);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.searchSingleIndex({ indexName:
'indexName' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.searchSingleIndex(indexName =
"")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->searchSingleIndex(
'',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.search_single_index(
index_name="",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.search_single_index("")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.searchSingleIndex(
indexName = ""
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response: SearchResponse = try await
client.searchSingleIndex(indexName: "")
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/query \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"params": "hitsPerPage=2&getRankingInfo=1"
}
'
/1/indexes/*/queries:
post:
tags:
- Search
operationId: search
x-use-read-transporter: true
x-cacheable: true
x-legacy-signature: true
x-acl:
- search
summary: Search multiple queries
description: >
Runs multiple search queries against one or more indices in a single API
request.
Use cases include:
- Searching different indices, such as products and marketing content.
- Run multiple queries on the same index with different parameters or
filters.
If you know the expected result type, use the `searchForHits` or
`searchForFacets` helper to simplify the response format.
requestBody:
required: true
description: >-
Multi-query search request body. Results are returned in the same
order as the requests.
content:
application/json:
schema:
title: searchMethodParams
type: object
additionalProperties: false
properties:
requests:
type: array
items:
$ref: '#/components/schemas/SearchQuery'
strategy:
$ref: '#/components/schemas/searchStrategy'
required:
- requests
responses:
'200':
description: OK
content:
application/json:
schema:
title: searchResponses
type: object
additionalProperties: false
properties:
results:
type: array
items:
$ref: '#/components/schemas/searchResult'
required:
- results
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SearchAsync(
new SearchMethodParams
{
Requests = new List
{
new SearchQuery(new SearchForHits { IndexName = "" }),
new SearchQuery(
new SearchForFacets
{
IndexName = "",
Type = Enum.Parse("Facet"),
Facet = "theFacet",
}
),
new SearchQuery(
new SearchForHits
{
IndexName = "",
Type = Enum.Parse("Default"),
}
),
},
Strategy = Enum.Parse("StopIfEnoughMatches"),
}
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.search(
searchMethodParams: SearchMethodParams(
requests: [
SearchForHits(
indexName: "",
),
SearchForFacets(
indexName: "",
type: SearchTypeFacet.fromJson("facet"),
facet: "theFacet",
),
SearchForHits(
indexName: "",
type: SearchTypeDefault.fromJson("default"),
),
],
strategy: SearchStrategy.fromJson("stopIfEnoughMatches"),
),
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.Search(client.NewApiSearchRequest(
search.NewEmptySearchMethodParams().SetRequests(
[]search.SearchQuery{*search.SearchForHitsAsSearchQuery(
search.NewEmptySearchForHits().SetIndexName("")), *search.SearchForFacetsAsSearchQuery(
search.NewEmptySearchForFacets().SetIndexName("").SetType(search.SearchTypeFacet("facet")).SetFacet("theFacet")), *search.SearchForHitsAsSearchQuery(
search.NewEmptySearchForHits().SetIndexName("").SetType(search.SearchTypeDefault("default")))}).SetStrategy(search.SearchStrategy("stopIfEnoughMatches"))))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
SearchResponses response = client.search(
new SearchMethodParams().setRequests(
Arrays.asList(new SearchForHits().setIndexName("").setQuery("").setHitsPerPage(50))
),
Hit.class
);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.search({
requests: [
{ indexName: 'theIndexName' },
{ indexName: 'theIndexName2', type: 'facet', facet: 'theFacet' },
{ indexName: 'theIndexName', type: 'default' },
],
strategy: 'stopIfEnoughMatches',
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.search(
searchMethodParams =
SearchMethodParams(
requests =
listOf(
SearchForHits(
indexName = "",
query = "",
hitsPerPage = 50,
)
)
)
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->search(
['requests' => [
['indexName' => '',
],
['indexName' => '',
'type' => 'facet',
'facet' => 'theFacet',
],
['indexName' => '',
'type' => 'default',
],
],
'strategy' => 'stopIfEnoughMatches',
],
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.search(
search_method_params={
"requests": [
{
"indexName": "",
},
{
"indexName": "",
"type": "facet",
"facet": "theFacet",
},
{
"indexName": "",
"type": "default",
},
],
"strategy": "stopIfEnoughMatches",
},
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.search(
Algolia::Search::SearchMethodParams.new(
requests: [
Algolia::Search::SearchForHits.new(index_name: ""),
Algolia::Search::SearchForFacets.new(index_name: "", type: "facet", facet: "theFacet"),
Algolia::Search::SearchForHits.new(index_name: "", type: "default")
],
strategy: "stopIfEnoughMatches"
)
)
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.search(
searchMethodParams = SearchMethodParams(
requests = Seq(
SearchForHits(
indexName = ""
),
SearchForFacets(
indexName = "",
`type` = SearchTypeFacet.withName("facet"),
facet = "theFacet"
),
SearchForHits(
indexName = "",
`type` = Some(SearchTypeDefault.withName("default"))
)
),
strategy = Some(SearchStrategy.withName("stopIfEnoughMatches"))
)
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response: SearchResponses = try await
client.search(searchMethodParams: SearchMethodParams(
requests: [
SearchQuery.searchForHits(SearchForHits(indexName: "")),
SearchQuery.searchForFacets(SearchForFacets(
facet: "theFacet",
indexName: "",
type: SearchTypeFacet.facet
)),
SearchQuery.searchForHits(SearchForHits(
indexName: "",
type: SearchTypeDefault.`default`
)),
],
strategy: SearchStrategy.stopIfEnoughMatches
))
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url 'https://algolia_application_id.algolia.net/1/indexes/*/queries' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"requests": [
{
"params": "hitsPerPage=2&getRankingInfo=1",
"indexName": "products",
"type": "default",
"extensions": {
"queryCategorization": {
"enableCategoriesRetrieval": false,
"enableAutoFiltering": false
}
}
}
],
"strategy": "none"
}
'
/1/indexes/{indexName}/facets/{facetName}/query:
post:
tags:
- Search
operationId: searchForFacetValues
x-use-read-transporter: true
x-cacheable: true
x-acl:
- search
summary: Search for facet values
description: >
Searches for values of a specified facet attribute.
- By default, facet values are sorted by decreasing count.
You can adjust this with the `sortFacetValueBy` parameter.
- Searching for facet values doesn't work if you have **more than 65
searchable facets and searchable attributes combined**.
parameters:
- name: facetName
description: >
Facet attribute in which to search for values.
This attribute must be included in the `attributesForFaceting` index
setting with the `searchable()` modifier.
in: path
required: true
schema:
type: string
- $ref: '#/components/parameters/IndexName'
requestBody:
content:
application/json:
schema:
title: searchForFacetValuesRequest
type: object
additionalProperties: false
properties:
facetQuery:
$ref: '#/components/schemas/facetQuery'
maxFacetHits:
$ref: '#/components/schemas/maxFacetHits'
params:
$ref: '#/components/schemas/paramsAsString'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/searchForFacetValuesResponse'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await
client.SearchForFacetValuesAsync("", "facetName");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.searchForFacetValues(
indexName: "",
facetName: "facetName",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err :=
client.SearchForFacetValues(client.NewApiSearchForFacetValuesRequest(
"", "facetName"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
SearchForFacetValuesResponse response =
client.searchForFacetValues("", "facetName");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.searchForFacetValues({ indexName:
'indexName', facetName: 'facetName' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.searchForFacetValues(indexName = "", facetName = "facetName")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->searchForFacetValues(
'',
'facetName',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.search_for_facet_values(
index_name="",
facet_name="facetName",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.search_for_facet_values("",
"facetName")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.searchForFacetValues(
indexName = "",
facetName = "facetName"
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.searchForFacetValues(indexName:
"", facetName: "facetName")
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/facets/lorem/query \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"params": "hitsPerPage=2&getRankingInfo=1",
"facetQuery": "george",
"maxFacetHits": 10
}
'
/1/indexes/{indexName}/browse:
post:
tags:
- Search
operationId: browse
x-use-read-transporter: true
x-acl:
- browse
summary: Browse for records
description: >
Retrieves records from an index, up to 1,000 per request.
Searching returns _hits_ (records augmented with highlighting and
ranking details).
Browsing returns matching records only.
Use browse to export your indices.
- The Analytics API doesn't collect data when using `browse`.
- Records are ranked by attributes and custom ranking.
- There's no ranking for typo tolerance, number of matched words,
proximity, or geo distance.
Browse requests automatically apply these settings:
- `advancedSyntax`: `false`
- `attributesToHighlight`: `[]`
- `attributesToSnippet`: `[]`
- `distinct`: `false`
- `enablePersonalization`: `false`
- `enableRules`: `false`
- `facets`: `[]`
- `getRankingInfo`: `false`
- `ignorePlurals`: `false`
- `optionalFilters`: `[]`
- `typoTolerance`: `true` or `false` (`min` and `strict` evaluate to
`true`)
If you send these parameters with your browse requests, they're ignored.
parameters:
- $ref: '#/components/parameters/IndexName'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/browseParams'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/browseResponse'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.BrowseAsync("");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.browse(
indexName: "",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.Browse(client.NewApiBrowseRequest(
""))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
BrowseResponse response = client.browse("",
Hit.class);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.browse({ indexName: 'cts_e2e_browse'
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.browse(indexName = "")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->browse(
'',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.browse(
index_name="",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.browse("")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.browse(
indexName = ""
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response: BrowseResponse = try await
client.browse(indexName: "")
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/browse \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"query": "",
"similarQuery": "comedy drama crime Macy Buscemi",
"filters": "(category:Book OR category:Ebook) AND _tags:published",
"facetFilters": [
[
"category:Book",
"category:-Movie"
],
"author:John Doe"
],
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"tagFilters": [
[
"Book",
"Movie"
],
"SciFi"
],
"sumOrFiltersScores": false,
"restrictSearchableAttributes": [
"title",
"author"
],
"facets": [
"*"
],
"facetingAfterDistinct": false,
"page": 0,
"offset": 42,
"length": 0,
"aroundLatLng": "40.71,-74.01",
"aroundLatLngViaIP": false,
"aroundRadius": 1,
"aroundPrecision": 10,
"minimumAroundRadius": 1,
"insideBoundingBox": "lorem",
"insidePolygon": [
[
47.3165,
4.9665,
47.3424,
5.0201,
47.32,
4.9
],
[
40.9234,
2.1185,
38.643,
1.9916,
39.2587,
2.0104
]
],
"naturalLanguages": [],
"ruleContexts": [
"mobile"
],
"personalizationImpact": 100,
"userToken": "test-user-123",
"getRankingInfo": false,
"synonyms": true,
"clickAnalytics": false,
"analytics": true,
"analyticsTags": [],
"percentileComputation": true,
"enableABTest": true,
"attributesToRetrieve": [
"author",
"title",
"content"
],
"ranking": [
"typo",
"geo",
"words",
"filters",
"proximity",
"attribute",
"exact",
"custom"
],
"relevancyStrictness": 90,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"highlightPreTag": "",
"highlightPostTag": "",
"snippetEllipsisText": "…",
"restrictHighlightAndSnippetArrays": false,
"hitsPerPage": 20,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"typoTolerance": true,
"allowTyposOnNumericTokens": true,
"disableTypoToleranceOnAttributes": [
"sku"
],
"ignorePlurals": [
"ca",
"es"
],
"removeStopWords": [
"ca",
"es"
],
"queryLanguages": [
"es"
],
"decompoundQuery": true,
"enableRules": true,
"enablePersonalization": false,
"queryType": "prefixLast",
"removeWordsIfNoResults": "firstWords",
"mode": "keywordSearch",
"semanticSearch": {
"eventSources": [
"lorem"
]
},
"advancedSyntax": false,
"optionalWords": "lorem",
"disableExactOnAttributes": [
"description"
],
"exactOnSingleWordQuery": "attribute",
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"distinct": 1,
"replaceSynonymsInHighlight": false,
"minProximity": 1,
"responseFields": [
"*"
],
"maxValuesPerFacet": 100,
"sortFacetValuesBy": "count",
"attributeCriteriaComputedByMinProximity": false,
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"lorem"
]
},
"values": {
"property1": {
"order": [
"lorem"
],
"sortRemainingBy": "count",
"hide": [
"lorem"
]
},
"property2": {
"order": [
"lorem"
],
"sortRemainingBy": "count",
"hide": [
"lorem"
]
}
}
},
"redirect": {
"url": "lorem"
},
"widgets": {
"banners": [
{
"image": {
"urls": [
{
"url": "lorem"
}
],
"title": "lorem"
},
"link": {
"url": "lorem"
}
}
]
}
},
"enableReRanking": true,
"reRankingApplyFilter": [
[]
],
"cursor": "jMDY3M2MwM2QwMWUxMmQwYWI0ZTN"
}
'
/1/indexes/{indexName}:
post:
tags:
- Records
operationId: saveObject
x-mcp-tool: true
x-acl:
- addObject
description: >
Adds a record to an index or replaces it.
- If the record doesn't have an object ID, a new record with an
auto-generated object ID is added to your index.
- If a record with the specified object ID exists, the existing record
is replaced.
- If a record with the specified object ID doesn't exist, a new record
is added to your index.
- If you add a record to an index that doesn't exist yet, a new index is
created.
To update _some_ attributes of a record, use the [`partial`
operation](https://www.algolia.com/doc/rest-api/search/partial-update-object).
To add, update, or replace multiple records, use the [`batch`
operation](https://www.algolia.com/doc/rest-api/search/batch).
This operation is subject to [indexing rate
limits](https://support.algolia.com/hc/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
summary: Add a new record (with auto-generated object ID)
parameters:
- $ref: '#/components/parameters/IndexName'
requestBody:
required: true
description: >-
The record. A schemaless object with attributes that are useful in the
context of search and discovery.
x-is-generic: true
content:
application/json:
schema:
type: object
example:
objectID: blackTShirt
name: Black T-shirt
color: '#000000'
responses:
'201':
description: Created
content:
application/json:
schema:
title: saveObjectResponse
type: object
additionalProperties: false
properties:
createdAt:
$ref: '#/components/schemas/createdAt'
taskID:
$ref: '#/components/schemas/taskID'
objectID:
$ref: '#/components/schemas/objectID'
required:
- taskID
- createdAt
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SaveObjectAsync(
"",
new Dictionary
{
{ "name", "Black T-shirt" },
{ "color", "#000000||black" },
{ "availableIn", "https://source.unsplash.com/100x100/?paris||Paris" },
{ "objectID", "myID" },
}
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.saveObject(
indexName: "",
body: {
'name': "Black T-shirt",
'color': "#000000||black",
'availableIn': "https://source.unsplash.com/100x100/?paris||Paris",
'objectID': "myID",
},
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.SaveObject(client.NewApiSaveObjectRequest(
"",
map[string]any{
"name": "Black T-shirt",
"color": "#000000||black",
"availableIn": "https://source.unsplash.com/100x100/?paris||Paris",
"objectID": "myID",
},
))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
SaveObjectResponse response = client.saveObject(
"",
new HashMap() {
{
put("name", "Black T-shirt");
put("color", "#000000||black");
put("availableIn", "https://source.unsplash.com/100x100/?paris||Paris");
put("objectID", "myID");
}
}
);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.saveObject({
indexName: '',
body: {
name: 'Black T-shirt',
color: '#000000||black',
availableIn: 'https://source.unsplash.com/100x100/?paris||Paris',
objectID: 'myID',
},
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.saveObject(
indexName = "",
body =
buildJsonObject {
put("name", JsonPrimitive("Black T-shirt"))
put("color", JsonPrimitive("#000000||black"))
put("availableIn", JsonPrimitive("https://source.unsplash.com/100x100/?paris||Paris"))
put("objectID", JsonPrimitive("myID"))
},
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->saveObject(
'',
['name' => 'Black T-shirt',
'color' => '#000000||black',
'availableIn' => 'https://source.unsplash.com/100x100/?paris||Paris',
'objectID' => 'myID',
],
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.save_object(
index_name="",
body={
"name": "Black T-shirt",
"color": "#000000||black",
"availableIn": "https://source.unsplash.com/100x100/?paris||Paris",
"objectID": "myID",
},
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.save_object(
"",
{
name: "Black T-shirt",
color: "#000000||black",
availableIn: "https://source.unsplash.com/100x100/?paris||Paris",
objectID: "myID"
}
)
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.saveObject(
indexName = "",
body = JObject(
List(
JField("name", JString("Black T-shirt")),
JField("color", JString("#000000||black")),
JField("availableIn", JString("https://source.unsplash.com/100x100/?paris||Paris")),
JField("objectID", JString("myID"))
)
)
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.saveObject(
indexName: "",
body: [
"name": "Black T-shirt",
"color": "#000000||black",
"availableIn": "https://source.unsplash.com/100x100/?paris||Paris",
"objectID": "myID",
]
)
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"objectID": "blackTShirt",
"name": "Black T-shirt",
"color": "#000000"
}
'
delete:
tags:
- Indices
operationId: deleteIndex
x-acl:
- deleteIndex
summary: Delete an index
description: >
Deletes an index and all its settings.
- Deleting an index doesn't delete its analytics data.
- If you try to delete a non-existing index, the operation is ignored
without warning.
- If the index you want to delete has replica indices, the replicas
become independent indices.
- If the index you want to delete is a replica index, you must first
unlink it from its primary index before you can delete it.
For more information, see [Delete replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/deleting-replicas).
externalDocs:
url: >-
https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/delete-indices
description: Delete indices.
parameters:
- $ref: '#/components/parameters/IndexName'
responses:
'200':
$ref: '#/components/responses/DeletedAt'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.DeleteIndexAsync("");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.deleteIndex(
indexName: "",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.DeleteIndex(client.NewApiDeleteIndexRequest(
""))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
DeletedAtResponse response =
client.deleteIndex("");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.deleteIndex({ indexName:
'theIndexName' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.deleteIndex(indexName = "")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->deleteIndex(
'',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.delete_index(
index_name="",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.delete_index("")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.deleteIndex(
indexName = ""
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.deleteIndex(indexName:
"")
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request DELETE \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME \
--header 'accept: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID'
/1/indexes/{indexName}/{objectID}:
get:
tags:
- Records
operationId: getObject
x-acl:
- search
summary: Retrieve a record
description: >
Retrieves one record by its object ID.
To retrieve more than one record, use the [`objects`
operation](https://www.algolia.com/doc/rest-api/search/get-objects).
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/ObjectID'
- name: attributesToRetrieve
in: query
description: >
Attributes to include with the records in the response.
This is useful to reduce the size of the API response.
By default, all retrievable attributes are returned.
`objectID` is always retrieved.
Attributes included in `unretrievableAttributes`
won't be retrieved unless the request is authenticated with the
admin API key.
schema:
type: array
items:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
description: The requested record.
x-is-generic: true
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.GetObjectAsync(
"",
"uniqueID",
new List { "attr1", "attr2" }
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.getObject(
indexName: "",
objectID: "uniqueID",
attributesToRetrieve: [
"attr1",
"attr2",
],
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.GetObject(client.NewApiGetObjectRequest(
"", "uniqueID").WithAttributesToRetrieve(
[]string{"attr1", "attr2"}))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
Object response = client.getObject("", "uniqueID",
Arrays.asList("attr1", "attr2"));
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.getObject({
indexName: 'theIndexName',
objectID: 'uniqueID',
attributesToRetrieve: ['attr1', 'attr2'],
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.getObject(
indexName = "",
objectID = "uniqueID",
attributesToRetrieve = listOf("attr1", "attr2"),
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->getObject(
'',
'uniqueID',
[
'attr1',
'attr2',
],
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.get_object(
index_name="",
object_id="uniqueID",
attributes_to_retrieve=[
"attr1",
"attr2",
],
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.get_object("", "uniqueID",
["attr1", "attr2"])
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.getObject(
indexName = "",
objectID = "uniqueID",
attributesToRetrieve = Some(Seq("attr1", "attr2"))
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response: [String: AnyCodable] = try await client.getObject(
indexName: "",
objectID: "uniqueID",
attributesToRetrieve: ["attr1", "attr2"]
)
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request GET \
--url 'https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/test-record-123?attributesToRetrieve=lorem' \
--header 'accept: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID'
put:
tags:
- Records
operationId: addOrUpdateObject
x-acl:
- addObject
summary: Add or replace a record
description: >
If a record with the specified object ID exists, the existing record is
replaced.
Otherwise, a new record is added to the index.
If you want to use auto-generated object IDs, use the [`saveObject`
operation](https://www.algolia.com/doc/rest-api/search/save-object).
To update _some_ attributes of an existing record, use the [`partial`
operation](https://www.algolia.com/doc/rest-api/search/partial-update-object)
instead.
To add, update, or replace multiple records, use the [`batch`
operation](https://www.algolia.com/doc/rest-api/search/batch).
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/ObjectID'
requestBody:
required: true
description: >-
The record. A schemaless object with attributes that are useful in the
context of search and discovery.
x-is-generic: true
content:
application/json:
schema:
type: object
example:
objectID: blackTShirt
name: Black T-shirt
color: '#000000'
responses:
'200':
$ref: '#/components/responses/UpdatedAtWithObjectId'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.AddOrUpdateObjectAsync(
"",
"uniqueID",
new Dictionary { { "key", "value" } }
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.addOrUpdateObject(
indexName: "",
objectID: "uniqueID",
body: {
'key': "value",
},
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err :=
client.AddOrUpdateObject(client.NewApiAddOrUpdateObjectRequest(
"", "uniqueID", map[string]any{"key": "value"}))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
UpdatedAtWithObjectIdResponse response = client.addOrUpdateObject(
"",
"uniqueID",
new HashMap() {
{
put("key", "value");
}
}
);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.addOrUpdateObject({
indexName: 'indexName',
objectID: 'uniqueID',
body: { key: 'value' },
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.addOrUpdateObject(
indexName = "",
objectID = "uniqueID",
body = buildJsonObject { put("key", JsonPrimitive("value")) },
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->addOrUpdateObject(
'',
'uniqueID',
['key' => 'value',
],
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.add_or_update_object(
index_name="",
object_id="uniqueID",
body={
"key": "value",
},
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.add_or_update_object("",
"uniqueID", {key: "value"})
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.addOrUpdateObject(
indexName = "",
objectID = "uniqueID",
body = JObject(List(JField("key", JString("value"))))
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.addOrUpdateObject(
indexName: "",
objectID: "uniqueID",
body: ["key": "value"]
)
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request PUT \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/test-record-123 \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"objectID": "blackTShirt",
"name": "Black T-shirt",
"color": "#000000"
}
'
delete:
tags:
- Records
operationId: deleteObject
x-acl:
- deleteObject
summary: Delete a record
description: >
Deletes a record by its object ID.
To delete more than one record, use the [`batch`
operation](https://www.algolia.com/doc/rest-api/search/batch).
To delete records matching a query, use the [`deleteBy`
operation](https://www.algolia.com/doc/rest-api/search/delete-by).
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/ObjectID'
responses:
'200':
$ref: '#/components/responses/DeletedAt'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.DeleteObjectAsync("",
"uniqueID");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.deleteObject(
indexName: "",
objectID: "uniqueID",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err :=
client.DeleteObject(client.NewApiDeleteObjectRequest(
"", "uniqueID"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
DeletedAtResponse response =
client.deleteObject("", "uniqueID");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.deleteObject({ indexName:
'', objectID: 'uniqueID' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.deleteObject(indexName = "",
objectID = "uniqueID")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->deleteObject(
'',
'uniqueID',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.delete_object(
index_name="",
object_id="uniqueID",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.delete_object("", "uniqueID")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.deleteObject(
indexName = "",
objectID = "uniqueID"
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.deleteObject(indexName:
"", objectID: "uniqueID")
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request DELETE \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/test-record-123 \
--header 'accept: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID'
/1/indexes/{indexName}/deleteByQuery:
post:
tags:
- Records
operationId: deleteBy
x-mcp-tool: true
x-acl:
- deleteIndex
summary: Delete records matching a filter
description: >
This operation doesn't accept empty filters.
This operation is resource-intensive.
Use it only if you can't get the object IDs of the records you want to
delete.
It's more efficient to get a list of object IDs with the [`browse`
operation](https://www.algolia.com/doc/rest-api/search/browse),
and then delete the records using the [`batch`
operation](https://www.algolia.com/doc/rest-api/search/batch).
This operation is subject to [indexing rate
limits](https://support.algolia.com/hc/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
externalDocs:
url: >-
https://support.algolia.com/hc/articles/16385098766353-Should-I-use-the-deleteBy-method-for-deleting-records-that-match-a-query
description: Should I use the deleteBy method for deleting records.
parameters:
- $ref: '#/components/parameters/IndexName'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/deleteByParams'
responses:
'200':
$ref: '#/components/responses/UpdatedAt'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.DeleteByAsync(
"",
new DeleteByParams { Filters = "brand:brandName" }
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.deleteBy(
indexName: "",
deleteByParams: DeleteByParams(
filters: "brand:brandName",
),
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.DeleteBy(client.NewApiDeleteByRequest(
"",
search.NewEmptyDeleteByParams().SetFilters("brand:brandName")))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
UpdatedAtResponse response = client.deleteBy("",
new DeleteByParams().setFilters("brand:brandName"));
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.deleteBy({ indexName: 'theIndexName',
deleteByParams: { filters: 'brand:brandName' } });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.deleteBy(
indexName = "",
deleteByParams = DeleteByParams(filters = "brand:brandName"),
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->deleteBy(
'',
['filters' => 'brand:brandName',
],
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.delete_by(
index_name="",
delete_by_params={
"filters": "brand:brandName",
},
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.delete_by("",
Algolia::Search::DeleteByParams.new(filters: "brand:brandName"))
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.deleteBy(
indexName = "",
deleteByParams = DeleteByParams(
filters = Some("brand:brandName")
)
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.deleteBy(
indexName: "",
deleteByParams: DeleteByParams(filters: "brand:brandName")
)
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/deleteByQuery \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"facetFilters": [
[
"category:Book",
"category:-Movie"
],
"author:John Doe"
],
"filters": "(category:Book OR category:Ebook) AND _tags:published",
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"tagFilters": [
[
"Book",
"Movie"
],
"SciFi"
],
"aroundLatLng": "40.71,-74.01",
"aroundRadius": 1,
"insideBoundingBox": "lorem",
"insidePolygon": [
[
47.3165,
4.9665,
47.3424,
5.0201,
47.32,
4.9
],
[
40.9234,
2.1185,
38.643,
1.9916,
39.2587,
2.0104
]
]
}
'
/1/indexes/{indexName}/clear:
post:
tags:
- Records
operationId: clearObjects
x-acl:
- deleteIndex
summary: Delete all records from an index
description: >
Deletes only the records from an index while keeping settings, synonyms,
and rules.
This operation is resource-intensive and subject to [indexing rate
limits](https://support.algolia.com/hc/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
parameters:
- $ref: '#/components/parameters/IndexName'
responses:
'200':
$ref: '#/components/responses/UpdatedAt'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.ClearObjectsAsync("");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.clearObjects(
indexName: "",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err :=
client.ClearObjects(client.NewApiClearObjectsRequest(
""))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
UpdatedAtResponse response =
client.clearObjects("");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.clearObjects({ indexName:
'theIndexName' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.clearObjects(indexName = "")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->clearObjects(
'',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.clear_objects(
index_name="",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.clear_objects("")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.clearObjects(
indexName = ""
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.clearObjects(indexName:
"")
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/clear \
--header 'accept: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID'
/1/indexes/{indexName}/{objectID}/partial:
post:
tags:
- Records
operationId: partialUpdateObject
x-mcp-tool: true
x-acl:
- addObject
summary: Add or update attributes
x-codegen-request-body-name: attributesToUpdate
description: >
Adds new attributes to a record, or updates existing ones.
- If a record with the specified object ID doesn't exist,
a new record is added to the index **if** `createIfNotExists` is true.
- If the index doesn't exist yet, this method creates a new index.
- Use first-level attributes only. Nested attributes aren't supported.
If you specify a nested attribute, this operation replaces its first-level ancestor.
To update attributes without replacing the full record, use these
built-in operations.
These operations are useful when the initial data isn't available.
- `Increment`: increment a numeric attribute.
- `Decrement`: decrement a numeric attribute.
- `Add`: append a number or string element to an array attribute.
- `Remove`: remove all matching number or string elements from an array
attribute made of numbers or strings.
- `AddUnique`: add a number or string element to an array attribute made
of numbers or strings only if it's not already present.
- `IncrementFrom`: increment a numeric integer attribute only if the
provided value matches the current value. Otherwise, the update is
ignored.
Example: If you pass an `IncrementFrom` value of 2 for the `version` attribute but the current value is 1, the API ignores the update.
If the object doesn't exist, the API only creates it if you pass an `IncrementFrom` value of 0.
- `IncrementSet`: increment a numeric integer attribute only if the
provided value is greater than the current value. Otherwise, the update
is ignored.
Example: If you pass an `IncrementSet` value of 2 for the `version` attribute and the current value is 1, the API updates the object.
If the object doesn't exist yet, the API only creates it if you pass an `IncrementSet` value greater than 0.
Specify an operation by providing an object with the attribute to update
as the key and its value as an object with these properties:
- `_operation`: the operation to apply on the attribute.
- `value`: the right-hand side argument to the operation, for example,
increment or decrement step, or a value to add or remove.
When updating multiple attributes or using multiple operations targeting
the same record, use a single partial update for faster processing.
This operation is subject to [indexing rate
limits](https://support.algolia.com/hc/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/ObjectID'
- name: createIfNotExists
description: Whether to create a new record if it doesn't exist.
in: query
schema:
type: boolean
default: true
requestBody:
required: true
description: Attributes with their values.
content:
application/json:
schema:
description: Attributes to update.
type: object
responses:
'200':
$ref: '#/components/responses/UpdatedAtWithObjectId'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.PartialUpdateObjectAsync(
"",
"uniqueID",
new Dictionary { { "attributeId", "new value" } }
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.partialUpdateObject(
indexName: "",
objectID: "uniqueID",
attributesToUpdate: {
'attributeId': "new value",
},
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err :=
client.PartialUpdateObject(client.NewApiPartialUpdateObjectRequest(
"", "uniqueID", map[string]any{"attributeId": "new value"}))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
UpdatedAtWithObjectIdResponse response = client.partialUpdateObject(
"",
"uniqueID",
new HashMap() {
{
put("attributeId", "new value");
}
}
);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.partialUpdateObject({
indexName: 'theIndexName',
objectID: 'uniqueID',
attributesToUpdate: { attributeId: 'new value' },
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.partialUpdateObject(
indexName = "",
objectID = "uniqueID",
attributesToUpdate = buildJsonObject { put("attributeId", JsonPrimitive("new value")) },
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->partialUpdateObject(
'',
'uniqueID',
['attributeId' => 'new value',
],
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.partial_update_object(
index_name="",
object_id="uniqueID",
attributes_to_update={
"attributeId": "new value",
},
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.partial_update_object("",
"uniqueID", {attributeId: "new value"})
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.partialUpdateObject(
indexName = "",
objectID = "uniqueID",
attributesToUpdate = JObject(List(JField("attributeId", JString("new value"))))
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.partialUpdateObject(
indexName: "",
objectID: "uniqueID",
attributesToUpdate: ["attributeId": "new value"]
)
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url 'https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/test-record-123/partial?createIfNotExists=true' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '{}'
/1/indexes/{indexName}/batch:
post:
tags:
- Records
x-acl:
- addObject
operationId: batch
x-mcp-tool: true
summary: Batch indexing operations on one index
description: >
Adds, updates, or deletes records in one index with a single API
request.
Batching index updates reduces latency and increases data integrity.
- Actions are applied in the order they're specified.
- Actions are equivalent to the individual API requests of the same
name.
This operation is subject to [indexing rate
limits](https://support.algolia.com/hc/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
parameters:
- $ref: '#/components/parameters/IndexName'
x-codegen-request-body-name: batchWriteParams
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/batchWriteParams'
required: true
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/batchResponse'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.BatchAsync(
"",
new BatchWriteParams
{
Requests = new List
{
new BatchRequest
{
Action = Enum.Parse("AddObject"),
Body = new Dictionary { { "key", "bar" }, { "foo", "1" } },
},
new BatchRequest
{
Action = Enum.Parse("AddObject"),
Body = new Dictionary { { "key", "baz" }, { "foo", "2" } },
},
},
}
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.batch(
indexName: "",
batchWriteParams: BatchWriteParams(
requests: [
BatchRequest(
action: Action.fromJson("addObject"),
body: {
'key': "bar",
'foo': "1",
},
),
BatchRequest(
action: Action.fromJson("addObject"),
body: {
'key': "baz",
'foo': "2",
},
),
],
),
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.Batch(client.NewApiBatchRequest(
"",
search.NewEmptyBatchWriteParams().SetRequests(
[]search.BatchRequest{
*search.NewEmptyBatchRequest().SetAction(search.Action("addObject")).SetBody(map[string]any{"key": "bar", "foo": "1"}),
*search.NewEmptyBatchRequest().SetAction(search.Action("addObject")).SetBody(map[string]any{"key": "baz", "foo": "2"}),
}),
))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
BatchResponse response = client.batch(
"",
new BatchWriteParams().setRequests(
Arrays.asList(
new BatchRequest().setAction(Action.ADD_OBJECT).setBody(
new HashMap() {
{
put("key", "bar");
put("foo", "1");
}
}
),
new BatchRequest().setAction(Action.ADD_OBJECT).setBody(
new HashMap() {
{
put("key", "baz");
put("foo", "2");
}
}
)
)
)
);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.batch({
indexName: '',
batchWriteParams: {
requests: [
{ action: 'addObject', body: { key: 'bar', foo: '1' } },
{ action: 'addObject', body: { key: 'baz', foo: '2' } },
],
},
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.batch(
indexName = "",
batchWriteParams =
BatchWriteParams(
requests =
listOf(
BatchRequest(
action = Action.entries.first { it.value == "addObject" },
body =
buildJsonObject {
put("key", JsonPrimitive("bar"))
put("foo", JsonPrimitive("1"))
},
),
BatchRequest(
action = Action.entries.first { it.value == "addObject" },
body =
buildJsonObject {
put("key", JsonPrimitive("baz"))
put("foo", JsonPrimitive("2"))
},
),
)
),
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->batch(
'',
['requests' => [
['action' => 'addObject',
'body' => ['key' => 'bar',
'foo' => '1',
],
],
['action' => 'addObject',
'body' => ['key' => 'baz',
'foo' => '2',
],
],
],
],
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.batch(
index_name="",
batch_write_params={
"requests": [
{
"action": "addObject",
"body": {
"key": "bar",
"foo": "1",
},
},
{
"action": "addObject",
"body": {
"key": "baz",
"foo": "2",
},
},
],
},
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.batch(
"",
Algolia::Search::BatchWriteParams.new(
requests: [
Algolia::Search::BatchRequest.new(action: "addObject", body: {key: "bar", foo: "1"}),
Algolia::Search::BatchRequest.new(action: "addObject", body: {key: "baz", foo: "2"})
]
)
)
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.batch(
indexName = "",
batchWriteParams = BatchWriteParams(
requests = Seq(
BatchRequest(
action = Action.withName("addObject"),
body = JObject(List(JField("key", JString("bar")), JField("foo", JString("1"))))
),
BatchRequest(
action = Action.withName("addObject"),
body = JObject(List(JField("key", JString("baz")), JField("foo", JString("2"))))
)
)
)
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.batch(
indexName: "",
batchWriteParams: SearchBatchWriteParams(requests: [
SearchBatchRequest(action: SearchAction.addObject, body: ["key": "bar", "foo": "1"]),
SearchBatchRequest(action: SearchAction.addObject, body: ["key": "baz", "foo": "2"]),
])
)
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/batch \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"requests": [
{
"action": "addObject",
"body": {
"name": "Betty Jane McCamey",
"company": "Vita Foods Inc.",
"email": "betty@mccamey.com"
}
},
{
"action": "addObject",
"body": {
"name": "Gayla geimer",
"company": "Ortman McCain Co.",
"email": "gayla@geimer.com"
}
}
]
}
'
/1/indexes/*/batch:
post:
tags:
- Records
x-acl:
- addObject
operationId: multipleBatch
x-mcp-tool: true
description: >
Adds, updates, or deletes records in multiple indices with a single API
request.
- Actions are applied in the order they are specified.
- Actions are equivalent to the individual API requests of the same
name.
This operation is subject to [indexing rate
limits](https://support.algolia.com/hc/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
summary: Batch indexing operations on multiple indices
requestBody:
required: true
content:
application/json:
schema:
title: batchParams
description: Batch parameters.
type: object
additionalProperties: false
properties:
requests:
type: array
items:
title: multipleBatchRequest
type: object
additionalProperties: false
properties:
action:
$ref: '#/components/schemas/action'
indexName:
$ref: '#/components/schemas/indexName'
body:
type: object
description: Operation arguments (varies with specified `action`).
required:
- action
- indexName
required:
- requests
examples:
batch:
summary: Batch indexing request to two indices
value:
requests:
- action: addObject
indexName: contacts
body:
name: Betty Jane McCamey
company: Vita Foods Inc.
email: betty@mccamey.com
- action: addObject
indexName: public_contacts
body:
name: Gayla Geimer
company: Ortman McCain Co.
email: gayla@geimer.com
responses:
'200':
description: OK
content:
application/json:
schema:
title: multipleBatchResponse
type: object
additionalProperties: false
properties:
objectIDs:
$ref: '#/components/schemas/objectIDs'
taskID:
type: object
description: Task IDs. One for each index.
additionalProperties:
$ref: '#/components/schemas/taskID'
required:
- taskID
- objectIDs
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.MultipleBatchAsync(
new BatchParams
{
Requests = new List
{
new MultipleBatchRequest
{
Action = Enum.Parse("AddObject"),
Body = new Dictionary { { "key", "value" } },
IndexName = "",
},
},
}
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.multipleBatch(
batchParams: BatchParams(
requests: [
MultipleBatchRequest(
action: Action.fromJson("addObject"),
body: {
'key': "value",
},
indexName: "",
),
],
),
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err :=
client.MultipleBatch(client.NewApiMultipleBatchRequest(
search.NewEmptyBatchParams().SetRequests(
[]search.MultipleBatchRequest{
*search.NewEmptyMultipleBatchRequest().SetAction(search.Action("addObject")).SetBody(map[string]any{"key": "value"}).SetIndexName(""),
}),
))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
MultipleBatchResponse response = client.multipleBatch(
new BatchParams().setRequests(
Arrays.asList(
new MultipleBatchRequest()
.setAction(Action.ADD_OBJECT)
.setBody(
new HashMap() {
{
put("key", "value");
}
}
)
.setIndexName("")
)
)
);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.multipleBatch({
requests: [{ action: 'addObject', body: { key: 'value' }, indexName: 'theIndexName' }],
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.multipleBatch(
batchParams =
BatchParams(
requests =
listOf(
MultipleBatchRequest(
action = Action.entries.first { it.value == "addObject" },
body = buildJsonObject { put("key", JsonPrimitive("value")) },
indexName = "",
)
)
)
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->multipleBatch(
['requests' => [
['action' => 'addObject',
'body' => ['key' => 'value',
],
'indexName' => '',
],
],
],
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.multiple_batch(
batch_params={
"requests": [
{
"action": "addObject",
"body": {
"key": "value",
},
"indexName": "",
},
],
},
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.multiple_batch(
Algolia::Search::BatchParams.new(
requests: [
Algolia::Search::MultipleBatchRequest.new(
action: "addObject",
body: {key: "value"},
index_name: ""
)
]
)
)
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.multipleBatch(
batchParams = BatchParams(
requests = Seq(
MultipleBatchRequest(
action = Action.withName("addObject"),
body = Some(JObject(List(JField("key", JString("value"))))),
indexName = ""
)
)
)
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.multipleBatch(batchParams:
BatchParams(requests: [MultipleBatchRequest(
action: SearchAction.addObject,
body: ["key": "value"],
indexName: ""
)]))
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url 'https://algolia_application_id.algolia.net/1/indexes/*/batch' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"requests": [
{
"action": "addObject",
"indexName": "contacts",
"body": {
"name": "Betty Jane McCamey",
"company": "Vita Foods Inc.",
"email": "betty@mccamey.com"
}
},
{
"action": "addObject",
"indexName": "public_contacts",
"body": {
"name": "Gayla Geimer",
"company": "Ortman McCain Co.",
"email": "gayla@geimer.com"
}
}
]
}
'
/1/indexes/*/objects:
post:
tags:
- Records
operationId: getObjects
x-use-read-transporter: true
x-cacheable: true
x-acl:
- search
summary: Retrieve records
description: |
Retrieves one or more records, potentially from different indices.
Records are returned in the same order as the requests.
requestBody:
required: true
description: Request object.
content:
application/json:
schema:
title: getObjectsParams
description: Request parameters.
type: object
additionalProperties: false
properties:
requests:
type: array
items:
title: getObjectsRequest
description: Request body for retrieving records.
type: object
additionalProperties: false
required:
- objectID
- indexName
properties:
indexName:
type: string
description: Index from which to retrieve the records.
example: books
objectID:
type: string
description: Object ID for the record to retrieve.
example: product-1
attributesToRetrieve:
type: array
items:
type: string
description: >
Attributes to retrieve.
If not specified, all retrievable attributes are
returned.
example:
- author
- title
- content
required:
- requests
responses:
'200':
description: OK
content:
application/json:
schema:
title: getObjectsResponse
type: object
additionalProperties: false
properties:
results:
type: array
description: Retrieved records.
items:
type: object
description: >
Retrieved record.
`null` if the requested `objectID` doesn't exist in the
index.
nullable: true
x-is-generic: true
message:
type: string
description: An optional status message.
example: Index INDEX_NAME does not exist.
required:
- results
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.GetObjectsAsync(
new GetObjectsParams
{
Requests = new List
{
new GetObjectsRequest { ObjectID = "uniqueID", IndexName = "" },
},
}
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.getObjects(
getObjectsParams: GetObjectsParams(
requests: [
GetObjectsRequest(
objectID: "uniqueID",
indexName: "",
),
],
),
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.GetObjects(client.NewApiGetObjectsRequest(
search.NewEmptyGetObjectsParams().SetRequests(
[]search.GetObjectsRequest{*search.NewEmptyGetObjectsRequest().SetObjectID("uniqueID").SetIndexName("")})))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
GetObjectsResponse response = client.getObjects(
new GetObjectsParams().setRequests(Arrays.asList(new GetObjectsRequest().setObjectID("uniqueID").setIndexName(""))),
Hit.class
);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.getObjects({ requests: [{ objectID:
'uniqueID', indexName: 'theIndexName' }] });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.getObjects(
getObjectsParams =
GetObjectsParams(
requests =
listOf(GetObjectsRequest(objectID = "uniqueID", indexName = ""))
)
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->getObjects(
['requests' => [
['objectID' => 'uniqueID',
'indexName' => '',
],
],
],
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.get_objects(
get_objects_params={
"requests": [
{
"objectID": "uniqueID",
"indexName": "",
},
],
},
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.get_objects(
Algolia::Search::GetObjectsParams.new(
requests: [Algolia::Search::GetObjectsRequest.new(algolia_object_id: "uniqueID", index_name: "")]
)
)
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.getObjects(
getObjectsParams = GetObjectsParams(
requests = Seq(
GetObjectsRequest(
objectID = "uniqueID",
indexName = ""
)
)
)
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response: GetObjectsResponse = try await client
.getObjects(getObjectsParams: GetObjectsParams(requests: [GetObjectsRequest(
objectID: "uniqueID",
indexName: ""
)]))
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request POST \
--url 'https://algolia_application_id.algolia.net/1/indexes/*/objects' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"requests": [
{
"attributesToRetrieve": [
"author",
"title",
"content"
],
"objectID": "product-1",
"indexName": "books"
}
]
}
'
/1/indexes/{indexName}/settings:
get:
tags:
- Indices
operationId: getSettings
x-mcp-tool: true
x-acl:
- settings
description: Retrieves an object with non-null index settings.
summary: Retrieve index settings
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/getVersion'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/settingsResponse'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.GetSettingsAsync("",
2);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.getSettings(
indexName: "",
getVersion: 2,
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.GetSettings(client.NewApiGetSettingsRequest(
"").WithGetVersion(2))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
SettingsResponse response = client.getSettings("",
2);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.getSettings({ indexName:
'cts_e2e_settings', getVersion: 2 });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.getSettings(indexName = "",
getVersion = 2)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->getSettings(
'',
2,
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.get_settings(
index_name="",
get_version=2,
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.get_settings("", 2)
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.getSettings(
indexName = "",
getVersion = Some(2)
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.getSettings(indexName:
"", getVersion: 2)
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request GET \
--url 'https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/settings?getVersion=1' \
--header 'accept: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID'
put:
tags:
- Indices
operationId: setSettings
x-acl:
- editSettings
description: >
Update the specified index settings.
Index settings that you don't specify are left unchanged.
Specify `null` to reset a setting to its default value.
For best performance, update the index settings before you add new
records to your index.
summary: Update index settings
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/ForwardToReplicas'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/indexSettings'
responses:
'200':
$ref: '#/components/responses/UpdatedAt'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SetSettingsAsync(
"",
new IndexSettings
{
PaginationLimitedTo = 10,
TypoTolerance = new TypoTolerance(Enum.Parse("False")),
},
true
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.setSettings(
indexName: "",
indexSettings: IndexSettings(
paginationLimitedTo: 10,
typoTolerance: TypoToleranceEnum.fromJson("false"),
),
forwardToReplicas: true,
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.SetSettings(client.NewApiSetSettingsRequest(
"",
search.NewEmptyIndexSettings().
SetPaginationLimitedTo(10).
SetTypoTolerance(search.TypoToleranceEnumAsTypoTolerance(search.TypoToleranceEnum("false"))),
).WithForwardToReplicas(true))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
UpdatedAtResponse response = client.setSettings(
"",
new IndexSettings().setPaginationLimitedTo(10).setTypoTolerance(TypoToleranceEnum.FALSE),
true
);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.setSettings({
indexName: 'cts_e2e_settings',
indexSettings: { paginationLimitedTo: 10, typoTolerance: 'false' },
forwardToReplicas: true,
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.setSettings(
indexName = "",
indexSettings =
IndexSettings(
paginationLimitedTo = 10,
typoTolerance = TypoToleranceEnum.entries.first { it.value == "false" },
),
forwardToReplicas = true,
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->setSettings(
'',
['paginationLimitedTo' => 10,
'typoTolerance' => 'false',
],
true,
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.set_settings(
index_name="",
index_settings={
"paginationLimitedTo": 10,
"typoTolerance": "false",
},
forward_to_replicas=True,
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.set_settings(
"",
Algolia::Search::IndexSettings.new(pagination_limited_to: 10, typo_tolerance: "false"),
true
)
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.setSettings(
indexName = "",
indexSettings = IndexSettings(
paginationLimitedTo = Some(10),
typoTolerance = Some(TypoToleranceEnum.withName("false"))
),
forwardToReplicas = Some(true)
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.setSettings(
indexName: "",
indexSettings: IndexSettings(
paginationLimitedTo: 10,
typoTolerance: SearchTypoTolerance.searchTypoToleranceEnum(SearchTypoToleranceEnum.`false`)
),
forwardToReplicas: true
)
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request PUT \
--url 'https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/settings?forwardToReplicas=true' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"attributesForFaceting": [
"author",
"filterOnly(isbn)",
"searchable(edition)",
"afterDistinct(category)",
"afterDistinct(searchable(publisher))"
],
"replicas": [
"virtual(prod_products_price_asc)",
"dev_products_replica"
],
"paginationLimitedTo": 100,
"unretrievableAttributes": [
"total_sales"
],
"disableTypoToleranceOnWords": [
"wheel",
"1X2BCD"
],
"attributesToTransliterate": [
"name",
"description"
],
"camelCaseAttributes": [
"description"
],
"decompoundedAttributes": {
"de": [
"name"
]
},
"indexLanguages": [
"ja"
],
"disablePrefixOnAttributes": [
"sku"
],
"allowCompressionOfIntegerArray": false,
"numericAttributesForFiltering": [
"equalOnly(quantity)",
"popularity"
],
"separatorsToIndex": "+#",
"searchableAttributes": [
"title,alternative_title",
"author",
"unordered(text)",
"emails.personal"
],
"userData": {
"settingID": "f2a7b51e3503acc6a39b3784ffb84300",
"pluginVersion": "1.6.0"
},
"customNormalization": {
"default": {
"ä": "ae",
"ü": "ue"
}
},
"attributeForDistinct": "url",
"maxFacetHits": 10,
"keepDiacriticsOnCharacters": "øé",
"customRanking": [
"desc(popularity)",
"asc(price)"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"ranking": [
"typo",
"geo",
"words",
"filters",
"proximity",
"attribute",
"exact",
"custom"
],
"relevancyStrictness": 90,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"highlightPreTag": "",
"highlightPostTag": "",
"snippetEllipsisText": "…",
"restrictHighlightAndSnippetArrays": false,
"hitsPerPage": 20,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"typoTolerance": true,
"allowTyposOnNumericTokens": true,
"disableTypoToleranceOnAttributes": [
"sku"
],
"ignorePlurals": [
"ca",
"es"
],
"removeStopWords": [
"ca",
"es"
],
"queryLanguages": [
"es"
],
"decompoundQuery": true,
"enableRules": true,
"enablePersonalization": false,
"queryType": "prefixLast",
"removeWordsIfNoResults": "firstWords",
"mode": "keywordSearch",
"semanticSearch": {
"eventSources": [
"lorem"
]
},
"advancedSyntax": false,
"optionalWords": "lorem",
"disableExactOnAttributes": [
"description"
],
"exactOnSingleWordQuery": "attribute",
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"distinct": 1,
"replaceSynonymsInHighlight": false,
"minProximity": 1,
"responseFields": [
"*"
],
"maxValuesPerFacet": 100,
"sortFacetValuesBy": "count",
"attributeCriteriaComputedByMinProximity": false,
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"lorem"
]
},
"values": {
"property1": {
"order": [
"lorem"
],
"sortRemainingBy": "count",
"hide": [
"lorem"
]
},
"property2": {
"order": [
"lorem"
],
"sortRemainingBy": "count",
"hide": [
"lorem"
]
}
}
},
"redirect": {
"url": "lorem"
},
"widgets": {
"banners": [
{
"image": {
"urls": [
{
"url": "lorem"
}
],
"title": "lorem"
},
"link": {
"url": "lorem"
}
}
]
}
},
"enableReRanking": true,
"reRankingApplyFilter": [
[]
]
}
'
/1/indexes/{indexName}/synonyms/{objectID}:
get:
tags:
- Synonyms
operationId: getSynonym
x-acl:
- settings
summary: Retrieve a synonym
description: >
Retrieves a synonym by its ID.
To find the object IDs for your synonyms,
use the [`search`
operation](https://www.algolia.com/doc/rest-api/search/search-synonyms).
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/parameters_ObjectID'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/synonymHit'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.GetSynonymAsync("",
"id1");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.getSynonym(
indexName: "",
objectID: "id1",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.GetSynonym(client.NewApiGetSynonymRequest(
"", "id1"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
SynonymHit response = client.getSynonym("", "id1");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.getSynonym({ indexName: 'indexName',
objectID: 'id1' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.getSynonym(indexName = "",
objectID = "id1")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->getSynonym(
'',
'id1',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.get_synonym(
index_name="",
object_id="id1",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.get_synonym("", "id1")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.getSynonym(
indexName = "",
objectID = "id1"
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.getSynonym(indexName:
"", objectID: "id1")
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request GET \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/synonyms/synonymID \
--header 'accept: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID'
put:
tags:
- Synonyms
operationId: saveSynonym
x-acl:
- editSettings
summary: Create or replace a synonym
description: >
If a synonym with the specified object ID doesn't exist, Algolia adds a
new one.
Otherwise, the existing synonym is replaced.
To add multiple synonyms in a single API request, use the [`batch`
operation](https://www.algolia.com/doc/rest-api/search/save-synonyms).
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/parameters_ObjectID'
- $ref: '#/components/parameters/ForwardToReplicas'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/synonymHit'
responses:
'200':
description: OK
content:
application/json:
schema:
title: saveSynonymResponse
type: object
additionalProperties: false
properties:
id:
$ref: '#/components/schemas/id'
taskID:
$ref: '#/components/schemas/taskID'
updatedAt:
$ref: '#/components/schemas/updatedAt'
required:
- taskID
- updatedAt
- id
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SaveSynonymAsync(
"",
"id1",
new SynonymHit
{
ObjectID = "id1",
Type = Enum.Parse("Synonym"),
Synonyms = new List { "car", "vehicule", "auto" },
},
true
);
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.saveSynonym(
indexName: "",
objectID: "id1",
synonymHit: SynonymHit(
objectID: "id1",
type: SynonymType.fromJson("synonym"),
synonyms: [
"car",
"vehicule",
"auto",
],
),
forwardToReplicas: true,
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.SaveSynonym(client.NewApiSaveSynonymRequest(
"", "id1",
search.NewEmptySynonymHit().SetObjectID("id1").SetType(search.SynonymType("synonym")).SetSynonyms(
[]string{"car", "vehicle", "auto"})).WithForwardToReplicas(true))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
SaveSynonymResponse response = client.saveSynonym(
"",
"id1",
new SynonymHit()
.setObjectID("id1")
.setType(SynonymType.SYNONYM)
.setSynonyms(Arrays.asList("car", "vehicule", "auto")),
true
);
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.saveSynonym({
indexName: 'indexName',
objectID: 'id1',
synonymHit: { objectID: 'id1', type: 'synonym', synonyms: ['car', 'vehicule', 'auto'] },
forwardToReplicas: true,
});
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response =
client.saveSynonym(
indexName = "",
objectID = "id1",
synonymHit =
SynonymHit(
objectID = "id1",
type = SynonymType.entries.first { it.value == "synonym" },
synonyms = listOf("car", "vehicule", "auto"),
),
forwardToReplicas = true,
)
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->saveSynonym(
'',
'id1',
['objectID' => 'id1',
'type' => 'synonym',
'synonyms' => [
'car',
'vehicule',
'auto',
],
],
true,
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.save_synonym(
index_name="",
object_id="id1",
synonym_hit={
"objectID": "id1",
"type": "synonym",
"synonyms": [
"car",
"vehicule",
"auto",
],
},
forward_to_replicas=True,
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.save_synonym(
"",
"id1",
Algolia::Search::SynonymHit.new(algolia_object_id: "id1", type: "synonym", synonyms: ["car", "vehicule", "auto"]),
true
)
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.saveSynonym(
indexName = "",
objectID = "id1",
synonymHit = SynonymHit(
objectID = "id1",
`type` = SynonymType.withName("synonym"),
synonyms = Some(Seq("car", "vehicule", "auto"))
),
forwardToReplicas = Some(true)
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.saveSynonym(
indexName: "",
objectID: "id1",
synonymHit: SynonymHit(objectID: "id1", type: SynonymType.synonym, synonyms: ["car", "vehicule", "auto"]),
forwardToReplicas: true
)
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request PUT \
--url 'https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/synonyms/synonymID?forwardToReplicas=true' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"objectID": "synonymID",
"type": "onewaysynonym",
"synonyms": [
"vehicle",
"auto"
],
"input": "car",
"word": "car",
"corrections": [
"vehicle",
"auto"
],
"placeholder": "",
"replacements": [
"street",
"st"
]
}
'
delete:
tags:
- Synonyms
operationId: deleteSynonym
x-acl:
- editSettings
summary: Delete a synonym
description: >
Deletes a synonym by its ID.
To find the object IDs of your synonyms, use the [`search`
operation](https://www.algolia.com/doc/rest-api/search/search-synonyms).
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/parameters_ObjectID'
- $ref: '#/components/parameters/ForwardToReplicas'
responses:
'200':
$ref: '#/components/responses/DeletedAt'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.DeleteSynonymAsync("",
"id1");
// print the response
Console.WriteLine(response);
- lang: dart
label: Dart
source: |-
// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.deleteSynonym(
indexName: "",
objectID: "id1",
);
// print the response
print(response);
- lang: go
label: Go
source: >-
// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err :=
client.DeleteSynonym(client.NewApiDeleteSynonymRequest(
"", "id1"))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
- lang: java
label: Java
source: >-
// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY");
// Call the API
DeletedAtResponse response =
client.deleteSynonym("", "id1");
// print the response
System.out.println(response);
- lang: javascript
label: JavaScript
source: >-
// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
const response = await client.deleteSynonym({ indexName:
'indexName', objectID: 'id1' });
// print the response
console.log(response);
- lang: kotlin
label: Kotlin
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
var response = client.deleteSynonym(indexName = "",
objectID = "id1")
// print the response
println(response)
- lang: php
label: PHP
source: >-
// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID',
'ALGOLIA_API_KEY');
// Call the API
$response = $client->deleteSynonym(
'',
'id1',
);
// print the response
var_dump($response);
- lang: python
label: Python
source: >-
# Initialize the client
# In an asynchronous context, you can use SearchClient instead,
which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.delete_synonym(
index_name="",
object_id="id1",
)
# print the response
print(response)
- lang: ruby
label: Ruby
source: >-
# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY")
# Call the API
response = client.delete_synonym("", "id1")
# print the response
puts(response)
- lang: scala
label: Scala
source: >-
// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey =
"ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.deleteSynonym(
indexName = "",
objectID = "id1"
),
Duration(100, "sec")
)
// print the response
println(response)
- lang: swift
label: Swift
source: >-
// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.deleteSynonym(indexName:
"", objectID: "id1")
// print the response
print(response)
- lang: cURL
label: curl
source: |-
curl --request DELETE \
--url 'https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/synonyms/synonymID?forwardToReplicas=true' \
--header 'accept: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID'
/1/indexes/{indexName}/synonyms/batch:
post:
tags:
- Synonyms
operationId: saveSynonyms
x-acl:
- editSettings
summary: Create or replace synonyms
description: >
If a synonym with the `objectID` doesn't exist, Algolia adds a new one.
Otherwise, existing synonyms are replaced.
This operation is subject to [indexing rate
limits](https://support.algolia.com/hc/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
parameters:
- $ref: '#/components/parameters/IndexName'
- $ref: '#/components/parameters/ForwardToReplicas'
- $ref: '#/components/parameters/ReplaceExistingSynonyms'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/synonymHits'
responses:
'200':
$ref: '#/components/responses/UpdatedAt'
'400':
$ref: '#/components/responses/BadRequest'
'402':
$ref: '#/components/responses/FeatureNotEnabled'
'403':
$ref: '#/components/responses/MethodNotAllowed'
'404':
$ref: '#/components/responses/IndexNotFound'
x-codeSamples:
- lang: csharp
label: C#
source: >-
// Initialize the client
var client = new SearchClient(new
SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SaveSynonymsAsync(
"",
new List
{
new SynonymHit
{
ObjectID = "id1",
Type = Enum.Parse("Synonym"),
Synonyms = new List { "car", "vehicule", "auto" },
},
new SynonymHit
{
ObjectID = "id2",
Type = Enum.Parse