newOS for Developers

Back to Search Methods

Post Search

Find posts with filtering and sorting

beginnerGET /post/list/search

Overview

Post search provides full-text search across post titles and descriptions. Results can be filtered by content type, author, and sorted by various criteria.

Unlike semantic search (which uses AI embeddings) or keyword search (which matches tags), post search performs text matching on the post content itself.

API Endpoint

GET/post/list/search

Query Parameters:

  • q — Search query string
  • contentType — Filter by type (image, video, text)
  • authorId — Filter by author ID
  • orderBy — Sort field (created, watts, updated)
  • direction — Sort direction (asc, desc)
  • page — Pagination cursor

Usage Example

import { searchPosts } from "@newgraph-signals/actions/post";

// Basic text search
const results = searchPosts({ q: "sunset beach" });

// With filters
const filteredResults = searchPosts({ 
  q: "sunset",
  contentType: "image",
  orderBy: "watts",
  direction: "desc"
});

// Raw API call
const response = await newgraphClient.api.post.listSearch({
  query: {
    q: "sunset beach",
    contentType: "image",
    orderBy: "created",
    direction: "desc"
  }
});

Response Schema

// PagedResponse<PostReadResponse>
{
  value: [
    {
      id: string;
      title: string;
      description: string;
      contentUrl: string;
      contentType: string;
      author: {
        id: string;
        username: string;
        displayName: string;
      };
      created: string;
      watts: number;
      tags: string[];
    }
  ],
  done: boolean;
  page: string;
}

Filtering Tips

Content Types

image, video, audio, text, link

Sort Fields

created (default), watts, updated