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]


Defining the words comics, journal, and novel as multi-way synonyms will result in searches for any one of those words for exdample: comnics returning documents containing at least one of the words in the synonym set (for example: records with comics or journal or novel are returned).

Setting up a Multi-way synonym

To get started with the multi-way synonym feature, follow the steps below. It is also available in a variety of programming languages.

For Javascript:

synonym = {
  synonyms: ["comics", "journal", "novel"],
};

client.collections("books").synonyms().upsert("comics-synonyms", synonym);

The code above simply creates and updates a synonym in the books collection called comics-synonyms.

For PHP

$synonym = [
  "synonyms" => ["comics", "journal", "novel"]
];
$client->collections['books']->synonyms->upsert('comics-synonyms', $synonym);

The code above simply creates and updates a synonym in the books collection called comics-synonyms.

For Ruby

synonym = {
  "synonyms" => ["comics", "journal", "novel"]
}
client.collections['books'].synonyms.upsert('comics-synonyms', synonym)

The code above simply creates and updates a synonym in the books collection called comics-synonyms.

For Python

synonym = {
  "synonyms": ["comics", "journal", "novel"]
}
client.collections['books'].synonyms.upsert('comics-synonyms', synonym)

The code above simply creates and updates a synonym in the books collection called comics-synonyms.

For Dart

final synonym = {
  "synonyms": ["comics", "journal", "novel"]
};

await client.collection('books').synonyms.upsert('comics-synonyms', synonym);

The code above simply creates and updates a synonym in the books collection called comics-synonyms.

For Java

SearchSynonymSchema synonym = new SearchSynonymSchema();
synonym.addSynonymsItem("comics").addSynonymsItem("journal").addSynonymsItem("novel");

client.collections("books").synonyms().upsert("comics-synonyms", synonym);

The code above simply creates and updates a synonym in the books collection called comics-synonyms.

For Swift

let synonymSchema = SearchSynonymSchema(synonyms: ["comics", "journal", "novel"])

let (searchSynonym, response) = try await client.collection(name: "books").synonyms().upsert(id: "comics-synonyms", synonymSchema)

The code above simply creates and updates a synonym in the books collection called comics-synonyms.

For Shell

curl "http://localhost:8108/collections/books/synonyms/comics-synonyms" -X PUT \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{
  "synonyms": ["comics", "journal", "novel"]
}'

The code above simply creates and updates a synonym in the books collection called comics-synonyms.

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!