NAME
Typesense::Client::Synonyms - query synonyms
SYNOPSIS
# multi-way: any of these finds the others
$ts->synonyms->put('products', 'laptop', {
synonyms => [qw(laptop notebook computer)],
});
# one-way: "laptop" also finds "ultrabook", but not the reverse
$ts->synonyms->put('products', 'laptop-narrow', {
root => 'laptop',
synonyms => [qw(ultrabook netbook)],
});
DESCRIPTION
Synonyms belong to a collection, not to the server. A collection built from scratch starts with none - so a reindex that creates a new collection and moves an alias onto it must re-push the synonyms, or the site silently loses them.
One-way versus multi-way
Without root, every term finds every other. With root, only the root expands: that is what you want when a general term should also reach the narrower ones - laptop finding ultrabook - without a search for the narrow term dragging the whole general set into its results.
METHODS
list
GET /collections/{c}/synonyms.
get
GET /collections/{c}/synonyms/{id}.
put
PUT /collections/{c}/synonyms/{id}. Creates or replaces. $body is { synonyms => [...] } or { root => '...', synonyms => [...] }.
delete
DELETE /collections/{c}/synonyms/{id}. Not an error if it does not exist.
SEE ALSO
AUTHOR
SeHarrys
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by SeHarrys.
This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.