Skip to main content

Overview

Returns state and a search function for executing natural language searches over project content. Supports filtering by content type and scoping by space or conversation. For integration guidance, see Semantic Search.

Usage Example

import { useSearchContent } from "@replyke/react-js";

function Search() {
  const { results, loading, search, reset } = useSearchContent();

  return (
    <div>
      <button onClick={() => search({ query: "onboarding tips", sourceTypes: ["entity"] })}>
        Search
      </button>
      {results.map((r) => (
        <div key={r.record.id}>{r.sourceType}{r.similarity.toFixed(3)}</div>
      ))}
    </div>
  );
}

Parameters

This hook returns an object. Call search with:
query
string
required
The natural language query string.
sourceTypes
("entity" | "comment" | "message")[]
Limit results to specific content types. Omit to search all types.
spaceId
string
Scope results to a specific space.
conversationId
string
Scope results to a specific conversation.
limit
number
Maximum number of results to return.

Returns

results
ContentSearchResult[]
Ranked search results.
loading
boolean
true while a search request is in progress.
error
string | null
Error message if the last search failed, otherwise null.
Executes the search and updates results.
reset
() => void
Clears results and error.