Example
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Search;
var client = new SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
client.SearchSingleIndex<Hit>(
indexName: "INDEX_NAME",
searchParams: new SearchParams(new SearchParamsObject { Query = "SEARCH_QUERY" }),
options: new RequestOptions
{
// Add a custom HTTP header to this request
Headers = new Dictionary<string, string> { { "extra-header", "greetings " } },
// Add query parameters to this request
QueryParameters = new Dictionary<string, object> { { "queryParam", "value" } },
// Adjust timeout this request
ReadTimeout = TimeSpan.FromSeconds(10),
}
);
import 'package:algoliasearch/algoliasearch.dart';
Future<void> main() async {
final client = SearchClient(
appId: 'ALGOLIA_APPLICATION_ID',
apiKey: 'ALGOLIA_API_KEY',
);
await client.searchSingleIndex(
indexName: 'INDEX_NAME',
searchParams: SearchParamsObject(query: 'SEARCH_QUERY'),
requestOptions: RequestOptions(
// Add a custom HTTP header to this request
headers: {'extra-header': 'greetings'},
// Add query parameters to this request
urlParameters: {'queryParam': 'value'},
// Adjust timeout this request
readTimeout: Duration(seconds: 10),
),
);
}
package main
import (
"github.com/algolia/algoliasearch-client-go/v4/algolia/search"
)
func main() {
client, _ := search.NewClient(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY",
)
searchParams := search.SearchParams{
SearchParamsObject: search.
NewEmptySearchParamsObject().
SetQuery("SEARCH_QUERY"),
}
client.SearchSingleIndex(
client.
NewApiSearchSingleIndexRequest("INDEX_NAME").
WithSearchParams(&searchParams),
// Add a custom HTTP header to this request
search.WithHeaderParam("extra-header", "greetings"),
// Add query parameters to this request
search.WithQueryParam("queryParam", "value"),
// Adjust timeout this request
search.WithReadTimeout(10*time.Second),
)
}
package org.example;
import com.algolia.api.SearchClient;
import com.algolia.config.RequestOptions;
import com.algolia.model.search.*;
import java.time.Duration;
public class Main {
public static void main(String[] args) {
var client = new SearchClient(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY"
);
var searchParams = new SearchParamsObject().setQuery("SEARCH_QUERY");
var requestOptions = new RequestOptions()
// Add a custom HTTP header to this request
.addExtraHeader("extra-header", "greetings")
// Add query parameters to this request
.addExtraQueryParameters("queryParam", "value")
// Adjust timeout for this request
.setReadTimeout(Duration.ofSeconds(10));
client.searchSingleIndex(
"INDEX_NAME",
searchParams,
Hit.class,
requestOptions
);
}
}
import { algoliasearch } from "algoliasearch";
const client = algoliasearch("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
await client.searchSingleIndex(
{
indexName: "INDEX_NAME",
searchParams: {
query: "SEARCH_QUERY",
},
},
{
// Add a custom HTTP header to this request
headers: {
"extra-header": "greetings",
},
// Add query parameters to this request
queryParameters: {
queryParam: "value",
},
// Adjust timeouts for this request
timeouts: {
connect: 10000,
read: 10000,
},
},
);
package org.example
import com.algolia.client.api.SearchClient
import com.algolia.client.model.search.SearchParamsObject
import com.algolia.client.transport.RequestOptions
import kotlin.time.DurationUnit
import kotlin.time.toDuration
suspend fun main() {
val client = SearchClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY"
)
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = SearchParamsObject(
query = "SEARCH_QUERY"
),
request_options = RequestOptions(
// Add a custom HTTP header to this request
headers = mapOf("extra-header" to "greetings"),
// Add query parameters to this request
urlParameters = mapOf("queryParam" to "value"),
// Adjust timeout for this request
readTimeout = 10.toDuration(DurationUnit.SECONDS)
)
)
}
<?php
require_once realpath(__DIR__.'/vendor/autoload.php');
use Algolia\AlgoliaSearch\Api\SearchClient;
$client = SearchClient::create(
appId: 'ALGOLIA_APPLICATION_ID',
apiKey: 'ALGOLIA_API_KEY',
);
$requestOptions = [
// Add custom HTTP header to this request
'headers' => ['extra-header' => 'greetings'],
// Add query parameter to this request
'queryParameters' => ['queryParam' => 'value'],
// Adjust timeout for this request
'readTimeout' => 10
];
$client->searchSingleIndex(
indexName: 'INDEX_NAME',
searchParams: ['query' => 'time'],
requestOptions: $requestOptions,
);
from algoliasearch.search.client import SearchClientSync
client = SearchClientSync(app_id="ALGOLIA_APPLICATION_ID", api_key="ALGOLIA_API_KEY")
results = client.search_single_index(
index_name="INDEX_NAME",
search_params={"query": "time"},
request_options={
# Add custom HTTP header to this request
"headers": {
"extra-header": "greetings",
},
# Add query parameter to this request
"query_parameters": {
"queryParam": "value",
},
# Adjust timeouts for this request
"timeouts": {
"read": 10_000,
"connect": 10_000,
},
},
)
require "algolia"
client = Algolia::SearchClient.create(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY"
)
client.search_single_index(
"INDEX_NAME",
{query: "SEARCH_QUERY"},
# Add a custom HTTP header to this request
header_params: {:"extra-header" => "greetings"},
# Add query parameters to this request
query_params: {queryParam: "value"}
)
package com.algolia.example
import scala.concurrent.duration.DurationInt
import scala.concurrent.ExecutionContext.Implicits.global
import algoliasearch.api.SearchClient
import algoliasearch.config.RequestOptions
import algoliasearch.search.SearchParamsObject
@main
def main(): Unit = {
val client = SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = Some(SearchParamsObject(query = Some("SEARCH_QUERY"))),
requestOptions = Some(RequestOptions(
// Add a custom HTTP header to this request
headers = Map("extra-header" -> "greetings"),
// Add query parameters to this request
queryParameters = Map("queryParam" -> "value"))),
// Adjust timeout for this request
readTimeout = Some(100.seconds)
)
}
import Core
@preconcurrency import Search
let client = try SearchClient(
appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY"
)
let searchResults: SearchResponse<Hit> = try await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchSearchParams.searchSearchParamsObject(
SearchSearchParamsObject(query: "SEARCH_QUERY")
),
requestOptions: RequestOptions(
// Add a custom HTTP header to this request
headers: ["extra-header": "greetings" ],
// Add query parameters to this request
queryParameters: ["queryParam": "value"],
// Adjust timeout for this request
readTimeout: 60
)
)
Reference
- C#
- Dart
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
IDictionary<string,string>
More headers to include in the request, as key-value pairs.
IDictionary<string,object>
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
TimeSpan
Time limit, in milliseconds, for the server to respond to read requests, such as retrieving data from Algolia.
TimeSpan
Time limit, in milliseconds, for the server to respond to write requests, such as sending data to Algolia.
TimeSpan
Time limit, in milliseconds, for the connection to open.
Map<String,dynamic>
More headers to include in the request, as key-value pairs.
Map<String,dynamic>
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Duration
Time limit, in milliseconds, for the server to respond to read requests, such as retrieving data from Algolia.
Duration
Time limit, in milliseconds, for the server to respond to write requests, such as sending data to Algolia.
Duration
Time limit, in milliseconds, for the connection to open.
map[string]string
More headers to include in the request, as key-value pairs.
Use the
search.WithHeaderParam() function to add them.url.Values
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Use the
search.WithQueryParam() function to add them.struct
Timeout durations for different types of network requests.
Hide child attributes
Hide child attributes
time.Duration
Time limit, in milliseconds, for the server to respond to read requests, such as retrieving data from Algolia.
Use the
search.WithReadTimeout() function to change this timeout.time.Duration
Time limit, in milliseconds, for the server to respond to write requests, such as sending data to Algolia.
Use the
search.WithWriteTimeout() function to change this timeout.time.Duration
Time limit, in milliseconds, for the connection to open.
Use the
search.WithConnectTimeout() function to change this timeout.Map<String,String>
More headers to include in the request, as key-value pairs.
Use the
RequestOptions.addExtraHeader() method to add them.Map<String,String>
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Use the
RequestOptions.addExtraQueryParameters() method to add them.Duration
Time limit, in milliseconds, for the server to respond to read requests, such as retrieving data from Algolia.
Use the
RequestOptions.setReadTimeout() method to change this timeout.Duration
Time limit, in milliseconds, for the server to respond to write requests, such as sending data to Algolia.
Use the
RequestOptions.setWriteTimeout() method to change this timeout.Duration
Time limit, in milliseconds, for the connection to open.
Use the
RequestOptions.setConnectTimeout() method to change this timeout.Record<string,string>
More headers to include in the request, as key-value pairs.
Record<string,any>
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
object
Timeout durations for different types of network requests.
Hide child attributes
Hide child attributes
Map<String,Any>
More headers to include in the request, as key-value pairs.
Map<String,Any>
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Duration
Time limit, in milliseconds, for the server to respond to read requests, such as retrieving data from Algolia.
Duration
Time limit, in milliseconds, for the server to respond to write requests, such as sending data to Algolia.
Duration
Time limit, in milliseconds, for the connection to open.
array<string,string>
More headers to include in the request, as key-value pairs.
array<string,string>
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
int
Time limit, in milliseconds, for the server to respond to read requests, such as retrieving data from Algolia.
int
Time limit, in milliseconds, for the server to respond to write requests, such as sending data to Algolia.
int
Time limit, in milliseconds, for the connection to open.
dict[str,str]>
More headers to include in the request, as key-value pairs.
dict[str,Any]
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
dict[str,int]]
Timeout durations for different types of network requests.
Hash<String,String>
More headers to include in the request, as key-value pairs.
Hash<String,String>
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Integer
Time limit, in milliseconds, for the server to respond to requests.
Integer
Time limit, in milliseconds, for the connection to open.
Map[String,String]
More headers to include in the request, as key-value pairs.
Map[String,String]
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Duration
Time limit, in milliseconds, for the server to respond to read requests, such as retrieving data from Algolia.
Duration
Time limit, in milliseconds, for the server to respond to write requests, such as sending data to Algolia.
Duration
Time limit, in milliseconds, for the connection to open.
Map[String,String]
More headers to include in the request, as key-value pairs.
Map[String,String]
More query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Duration
Time limit, in milliseconds, for the server to respond to read requests, such as retrieving data from Algolia.
Duration
Time limit, in milliseconds, for the server to respond to write requests, such as sending data to Algolia.