Skip to main content

Search Quizzes (POST)

Search for public quizzes with advanced filtering and highlighting.

Request Body

q
string
required
Search query text
offset
integer
default:"0"
Number of results to skip (for pagination)
limit
integer
default:"20"
Maximum number of results to return
filter
string
Filter expression (Meilisearch syntax)Examples:
  • imported_from_kahoot = false
  • user = "username"
sort
array
Array of sort criteriaExamples:
  • ["created_at:desc"]
  • ["likes:desc", "views:desc"]
attributesToRetrieve
array
default:"['*']"
Attributes to include in results
attributesToCrop
array
Attributes to crop to specified length
cropLength
integer
default:"200"
Maximum length for cropped attributes
attributesToHighlight
array
Attributes to highlight matching terms in

Example Request

{
  "q": "science",
  "offset": 0,
  "limit": 10,
  "filter": "imported_from_kahoot = false",
  "sort": ["likes:desc"],
  "attributesToHighlight": ["title", "description"]
}

Response

hits
array
Array of matching quiz objects
query
string
The search query that was executed
limit
integer
Number of results requested
offset
integer
Pagination offset
processingTimeMs
integer
Search processing time in milliseconds

Hit Object

id
uuid
Quiz ID
title
string
Quiz title
description
string
Quiz description
user
string
Username of quiz creator
imported_from_kahoot
boolean
Whether quiz was imported from Kahoot
formatted
object
Formatted version with highlighted matches (when using attributesToHighlight)

Example Response

{
  "hits": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "title": "Science Fundamentals",
      "description": "Test your knowledge of basic science concepts",
      "user": "teacher123",
      "imported_from_kahoot": false,
      "formatted": {
        "title": "<em>Science</em> Fundamentals",
        "description": "Test your knowledge of basic <em>science</em> concepts"
      }
    }
  ],
  "query": "science",
  "limit": 10,
  "offset": 0,
  "processingTimeMs": 12
}

Search Quizzes (GET)

Search for quizzes using URL parameters (simpler alternative to POST).

Query Parameters

q
string
required
Search query text
offset
integer
default:"0"
Pagination offset
limit
integer
default:"20"
Number of results
filter
string
Filter expression
cropLength
integer
default:"200"
Crop length for text fields
attributesToHighlight
string
default:"*"
Comma-separated attributes to highlight

Example Request

GET /api/v1/search/?q=mathematics&limit=10&filter=imported_from_kahoot=false

Response

Same format as POST endpoint.

Search Features

Meilisearch provides typo-tolerant full-text search across:
  • Quiz titles
  • Quiz descriptions
  • Creator usernames

Filtering

Filter quizzes by:
  • Import status: imported_from_kahoot = true/false
  • Creator: user = "username"
  • Custom filters based on indexed attributes

Sorting

Sort results by:
  • likes:desc - Most liked
  • views:desc - Most viewed
  • plays:desc - Most played
  • created_at:desc - Newest first
  • created_at:asc - Oldest first

Highlighting

Request highlighted results to show where search terms matched:
{
  "attributesToHighlight": ["title", "description"]
}
Matching terms are wrapped in <em> tags in the formatted field.

Pagination

Use offset and limit for pagination:
// Page 1
{ "offset": 0, "limit": 20 }

// Page 2  
{ "offset": 20, "limit": 20 }

// Page 3
{ "offset": 40, "limit": 20 }

Search Examples

curl -X POST https://classquiz.example.com/api/v1/search/ \
  -H "Content-Type: application/json" \
  -d '{
    "q": "geography",
    "limit": 10
  }'

Search with Filters

curl -X POST https://classquiz.example.com/api/v1/search/ \
  -H "Content-Type: application/json" \
  -d '{
    "q": "history",
    "limit": 10,
    "filter": "imported_from_kahoot = false",
    "sort": ["likes:desc"]
  }'

Search by User

curl -X GET "https://classquiz.example.com/api/v1/search/?q=&filter=user%3D%22teacher123%22&limit=20"

Highlighted Results

curl -X POST https://classquiz.example.com/api/v1/search/ \
  -H "Content-Type: application/json" \
  -d '{
    "q": "math",
    "limit": 5,
    "attributesToHighlight": ["title", "description"]
  }'

Search Tips

Typo Tolerance

Meilisearch automatically handles typos:
  • “sceince” → finds “science”
  • “mathmatic” → finds “mathematics”

Empty Query

An empty query (q: "") returns all quizzes, useful with filters:
{
  "q": "",
  "filter": "user = \"teacher123\"",
  "sort": ["created_at:desc"]
}

Performance

Meilisearch is extremely fast - most searches complete in under 50ms. The processingTimeMs field shows actual search time.

Index Maintenance

The search index is automatically updated when:
  • New quizzes are created
  • Quizzes are made public
  • Quizzes are updated
  • Quizzes are deleted

Build docs developers (and LLMs) love