Skip to content

Find similar objects

How do you find similar objects in Tallyfy Answers?

The recommendation endpoint lets you find objects similar to a specified reference object.

This similarity search uses vector embeddings to find objects with related characteristics. It’s useful for recommendation systems, content discovery, and finding related items.

How does similarity search work in Tallyfy Answers?

Here’s how Tallyfy Answers uses semantic similarity to find related objects:

  1. Tallyfy converts each object’s text content into vector embeddings (numerical representations)
  2. When searching for similar objects, Tallyfy compares vector distances
  3. Objects with closer vector distances are more similar
  4. Tallyfy ranks results by similarity score from most to least similar

API endpoint

GET /collections/{collection_name}/recommend/{object_id}

Path parameters

ParameterTypeRequiredDescription
collection_namestringYesName of the collection to search in
object_idstringYesID of the reference object to find similar objects to

Query parameters

ParameterTypeRequiredDefaultDescription
limitintegerNo4Maximum number of similar objects to return (1-20)

Response

A successful request returns a 200 OK status code and a JSON response containing:

{
"results": [
{
"id": "product-456",
"score": 0.89,
"document": {
"name": "Bluetooth Speaker",
"description": "Portable waterproof speaker with 20-hour battery life",
"price": 129.99,
"categories": ["electronics", "audio"]
}
},
{
"id": "product-789",
"score": 0.72,
"document": {
"name": "Wireless Earbuds",
"description": "Premium noise-canceling earbuds with charging case",
"price": 99.99,
"categories": ["electronics", "audio"]
}
}
],
"meta": {
"limit": 10,
"found": 2
}
}

Response fields

FieldTypeDescription
resultsarrayList of similar objects with similarity scores
results[].idstringUnique identifier of the similar object
results[].scorefloatSimilarity score (0.0-1.0)1 where higher is more similar
results[].documentobjectFull content of the similar object
meta.limitintegerMaximum number of results requested
meta.foundintegerTotal number of similar objects found

Error scenarios

StatusDescription
404Collection or reference object not found
400Invalid parameters or filter syntax

Example request

Terminal window
# Find objects similar to article-123, limit to 5 results
curl -X GET "https://answers.tallyfy.com/collections/docs/recommend/article-123?limit=5" \
-H "Authorization: Bearer your_api_key"
  • Product recommendations: “Customers who viewed this also viewed…”
  • Content discovery: Finding related articles or documentation
  • Similarity matching: Identifying near-duplicate content
  • Alternative suggestions: Offering similar options when an item is unavailable
  • Start with a lower min_score threshold and adjust based on result quality
  • Use the filter parameter to combine similarity with business rules
  • You’ll get better recommendations if your objects contain rich, descriptive text
  • Include diverse object attributes to improve similarity matching accuracy

Answers > Collections

Collections in Tallyfy Answers group similar objects together, like database tables. They…

Objects > Get an object

Retrieve a specific object from a Tallyfy Answers collection using its unique identifier…

Answers > Objects

Objects are JSON data records in Tallyfy Answers that belong to collections. They can be…

Answers > Search

Tallyfy Answers search combines AI semantic understanding with traditional keyword matching to…

Footnotes

  1. Cosine similarity scoring where perfect match equals 1.0, high similarity above 0.8, low below 0.5