> ## Documentation Index
> Fetch the complete documentation index at: https://docs.videodb.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Collection

> Search across all videos in a collection

Search across all media files in a collection using semantic or keyword search.

<CodeGroup>
  ```python Python theme={null}
  import videodb
  from videodb import SearchType, IndexType

  conn = videodb.connect(api_key="your_api_key")
  coll = conn.get_collection()

  # Search spoken content
  results = coll.search(
      query="product launch",
      search_type=SearchType.semantic,
      index_type=IndexType.spoken_word
  )

  for result in results.shots:
      print(f"Video: {result.video_id}")
      print(f"Match: {result.text}")
      print(f"Time: {result.start} - {result.end}")
  ```

  ```javascript Node.js theme={null}
  import { connect, SearchType, IndexType } from 'videodb';

  const conn = connect({ apiKey: 'your_api_key' });
  const coll = await conn.getCollection();

  // Search spoken content
  const results = await coll.search(
      'product launch',
      SearchType.semantic,
      IndexType.spoken_word
  );

  for (const result of results.shots) {
      console.log(`Video: ${result.video_id}`);
      console.log(`Match: ${result.text}`);
      console.log(`Time: ${result.start} - ${result.end}`);
  }
  ```
</CodeGroup>

<Note>
  * Videos must be indexed before search works (use `video.index_spoken_words()` or `video.index_scenes()`)
  * Use `IndexType.scene` for visual search across scenes
  * Add metadata during indexing for filtered searches
</Note>

<CardGroup cols={2}>
  <Card title="Collection Search Guide" icon="search" href="/pages/understand/search-and-retrieval/collection-search">
    Advanced search with metadata filtering
  </Card>

  <Card title="Video Indexing" icon="list" href="/api-reference/videos/indexing/create_video_index">
    Create indexes for searchable content
  </Card>
</CardGroup>


## OpenAPI

````yaml POST /collection/{collection_id}/search/
openapi: 3.0.3
info:
  title: VideoDB Server API
  description: >
    VideoDB Server API for video, audio, and image processing with AI
    capabilities.

    This API provides comprehensive video management, search, indexing, and
    AI-powered features.
  version: 1.0.0
  contact:
    name: VideoDB Support
    url: https://videodb.io
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://api.videodb.io
    description: Production server
  - url: https://staging-api.videodb.io
    description: Staging server
security:
  - ApiKeyAuth: []
tags:
  - name: Authentication
    description: User authentication and API key management
  - name: Collections
    description: Collection management operations
  - name: Videos
    description: Video upload, processing, and management
  - name: Audio
    description: Audio management operations
  - name: Images
    description: Image management operations
  - name: Search
    description: Content search and indexing
  - name: AI Generation
    description: AI-powered content generation
  - name: Billing
    description: Billing and usage management
  - name: RTStream
    description: Real-time streaming operations
  - name: Utilities
    description: Utility endpoints
  - name: Meeting
    description: Meeting recording and management
  - name: Capture
    description: Capture session management for recording streams
  - name: Editor
    description: Timeline editor operations
  - name: Transcode
    description: Media transcoding operations
  - name: Assets
    description: Cross-collection asset listing
paths:
  /collection/{collection_id}/search/:
    post:
      summary: Search within collection
      parameters:
        - name: collection_id
          in: path
          required: true
          schema:
            type: string
            example: default
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - query
              properties:
                query:
                  type: string
                  example: search query
                index_type:
                  type: string
                  enum:
                    - spoken_word
                    - scene
                  example: spoken_word
                search_type:
                  type: string
                  enum:
                    - semantic
                    - custom
                  example: semantic
                score_threshold:
                  type: number
                  example: 0.2
                result_threshold:
                  type: integer
                  example: 10
                stitch:
                  type: boolean
                  example: true
                rerank:
                  type: boolean
                  example: false
                filter:
                  type: array
                  items:
                    type: object
      responses:
        '200':
          description: Search results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResult'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    SearchResult:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          type: object
          properties:
            query:
              type: string
              example: search query
            results:
              type: array
              items:
                type: object
                properties:
                  video_id:
                    type: string
                    example: m-12345
                  start:
                    type: number
                    example: 10.5
                  end:
                    type: number
                    example: 20.3
                  text:
                    type: string
                    example: matched content
                  score:
                    type: number
                    example: 0.95
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-access-token
      description: API key for authentication (sk-xxx format)

````