SearchSimilarity Search

Similarity Search

Find similar content across text, images, and records based on their characteristics and patterns.

Text Similarity

When you want to find related documents based on their concepts, use text similarity search. For example, if you have a document about AI technology, use similar.text() to find other documents discussing related concepts like machine learning.

const {
  data: { payload }
} = await unbody.get
                .textBlock
                .similar.text("artificial intelligence", {
                  certainty: 0.8
                })
                .exec();

Advanced Text Similarity

Sometimes you need to steer your search results toward specific themes while maintaining similarity. Use advanced text similarity with concept steering to fine-tune your results based on particular topics.

const {
  data: { payload }
} = await unbody.get
                .textDocument
                .similar.text(["AI", "machine learning"], {
                  certainty: 0.65,
                  moveTo: {
                    concepts: ["future"],
                    force: 0.5
                  }
                })
                .select("title", "text", "autoSummary", "authors", "createdAt")
                .limit(2)
                .exec();

Image Similarity

When you need to find visually similar images regardless of their metadata, use similar.image() method. This helps you discover images with matching colors, objects, or compositions. Learn more about Visual Similarity.

const {
  data: { payload }
} = await unbody.get
                .imageBlock
                .similar.image("https://www.treadfirst.co.uk/wp-content/uploads/2023/05/riseBlog.jpg", {
                  certainty: 0.65
                })
                .select("originalName", "url")
                .limit(5)
                .exec();

Record Similarity

When you have a document you like and want to find similar ones, use .similar.record() method. Learn more about Record Similarity.

const {
  data: { payload }
} = await unbody.get
                .textDocument
                .similar.record("201704f2-1aee-53bc-b6d2-463baf3f160f", {
                  certainty: 0.75
                })
                .select("title", "originalName", "autoSummary", "authors")
                .limit(5)
                .exec();
©2024 Unbody