newOS for Developers

Back to Search Methods

Semantic Search

AI-powered vector search for content discovery

intermediatePOST /search/semantic

Overview

Semantic search uses LangChain and OpenSearch vector embeddings to find content based on meaning rather than exact keyword matches. Queries are converted to vectors and compared against indexed content embeddings for similarity.

This is useful for natural language queries like "photos of sunsets" which would match content tagged with "beach evening" or "golden hour photography".

API Endpoint

POST/search/semantic

Query Parameters:

  • query.query — Natural language search string

Usage Example

import { semanticSearch } from "@newgraph-signals/actions/search";

// Using the signals-based action
const results = semanticSearch({ q: "photos of nature" });

// The action returns a signal that updates with results
effect(() => {
  console.log("Search results:", results.value);
});

// Raw API call
const response = await newgraphClient.api.search.semanticList({
  query: { query: "photos of nature" }
});

Response Schema

{
  value: [
    {
      id: string;           // Post or mood ID
      contentUrl: string;   // Media URL
      description: string;  // Content description
      score: number;        // Similarity score (0-1)
    }
  ]
}

Performance Notes

Latency

~500ms average (includes embedding generation)

Backend

LangChain + OpenSearch vector index