How to create and update an alias in Typesense?
Outline: [Article Title]
Keyword: [Enter Targeted Keyword]
Keyword MSV: [Enter Targeted Keyword’s Monthly Search Volume]
Author: [Enter Author Name]
Due Date: [Enter Due Date]
Publish Date: [Enter Desired Publish Date]
User Persona: [Enter Targeted Reader and/or User Persona]
Creating an alias in Typesense is quite easy.Here’s an set of an example of how to create and update aliases in Typesense using a variety of programming languages:
For Javascript
aliased_collection = {
collection_name: "newsletter_feb9",
};
client.aliases().upsert("newsletter", aliased_collection);
The code above simply Creates and updates an alias called newsletter
to the newsletter_feb9
collection.
For PHP
$aliasedCollection = [
'collection_name' => 'newsletter_feb9'
]
$client->aliases->upsert('newsletter', $aliasedCollection)
The code above simply Creates and updates an alias called newsletter
to the newsletter_feb9
collection.
For Python
aliased_collection = {
'collection_name': 'newsletter_feb9'
}
client.aliases.upsert('newsletter', aliased_collection)
The code above simply Creates and updates an alias called newsletter
to the newsletter_feb9
collection.
For Ruby
aliased_collection = {
'collection_name' => 'newsletter_feb9'
}
client.aliases.upsert('newsletter', aliased_collection)
The code above simply Creates and updates an alias called newsletter
to the newsletter_feb9
collection.
For Dart
final aliasedCollection = {
'collection_name': 'newsletter_feb9'
};
await client.aliases.upsert('newsletter', aliased_collection);
The code above simply Creates and updates an alias called newsletter
to the newsletter_feb9
collection.
For Java
CollectionAlias collectionAlias = new CollectionAlias();
collectionAlias.collectionName("newsletter_feb9");
client.aliases().upsert("newsletter", collectionAlias);
The code above simply Creates and updates an alias called newsletter
to the newsletter_feb9
collection.
For Swift
let collection = CollectionAliasSchema(collectionName: "newsletter_feb9")
let (collectionAlias, response) = try await client.aliases().upsert(name: "newsletter", collection: collection)
The code above simply Creates and updates an alias called newsletter
to the newsletter_feb9
collection.
For any other languages
Typesense has an HTTP REST API. As a result, you can make API calls to it using any HTTP library in your preferred language. The official client libraries are simply thin wrappers around the API that include a retry mechanism.
Closing
Typesense was built with several distinctive features primarily aimed at making the developer’s job easier while also giving customer as well as user the ability to provide a better search experience as possible.This article may have been entertaining as well as instructive in terms of how to install typesense from the ground up on a variety of platforms. Join Aviyel’s community to learn more about the open source project, get tips on how to contribute, and join active dev groups.
Call-to-Action
Aviyel is a collaborative platform that assists open source project communities in monetizing and long-term sustainability. To know more visit Aviyel.com and find great blogs and events, just like this one! Sign up now for early access, and don’t forget to follow us on our socials!