Mock Search Results API Response
Generate a mock search results JSON response with query metadata, facets, and highlighted matches. Test search UI components and autocomplete.
Detailed Explanation
Search Results Response
Search endpoints return results along with metadata about the query itself. This mock generates a response that includes the original query, result count, and faceted filtering data.
Response Structure
{
"data": [
{
"id": "uuid",
"title": "string",
"description": "string",
"score": "number",
"category": "enum(article,product,page)"
}
],
"meta": {
"query": "search term",
"total": 142,
"page": 1,
"perPage": 10,
"responseTimeMs": 45
}
}
Search-Specific Fields
| Field | Purpose |
|---|---|
score |
Relevance score for ranking results |
meta.query |
Echo of the original search query |
meta.responseTimeMs |
Server-side processing time |
Relevance Scoring
The score field (typically 0.0 to 1.0 or 0 to 100) indicates how well each result matches the query. Frontend code can use this to:
- Sort results by relevance (default) or allow re-sorting by date/name
- Show a relevance indicator or "best match" badge
- Filter out low-relevance results below a threshold
Highlighting
In production, search APIs often return highlighted snippets with the matching terms wrapped in <em> or <mark> tags. This mock generates plain text, but you can post-process the results to add highlighting on the client side.
Performance Indicator
The responseTimeMs field helps users understand search performance and enables monitoring dashboards. Google Search famously displays this ("About 142 results (0.045 seconds)").
Use Case
Search UI developers can use this mock to build and test search results pages with relevance sorting, query echo, pagination, and performance indicators before integrating with a real search backend like Elasticsearch or Algolia.