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

# Search document pages (deprecated)

>  Get the most relevant pages from documents matching the provided metadata filter. <br />
The `metadata_filter` parameter supports the same MongoDB-like query syntax as the [/answer](api-reference/documents/get-document-answer) endpoint. See [/answer](api-reference/documents/get-document-answer) endpoint documentation for detailed examples of metadata filtering.




## OpenAPI

````yaml post /api/v1/documents/pages/search
openapi: 3.1.0
info:
  title: Fieldwise API
  description: API for the Fieldwise platform.
  version: 1.0.0
servers:
  - url: https://api.fieldwise.ai
security:
  - ApiKeyAuth: []
paths:
  /api/v1/documents/pages/search:
    post:
      tags:
        - Documents
      summary: Search Document Pages
      description: >-
        Get the most relevant pages from documents matching the provided
        metadata filter.


        The metadata_filter parameter supports the same MongoDB-like query
        syntax as the /answer endpoint.

        See /answer endpoint documentation for detailed examples of metadata
        filtering.
      operationId: search_document_pages_api_v1_documents_pages_search_post
      parameters:
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RelevantPagesRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RelevantPagesResponse'
        '401':
          description: Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetail'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetail'
      deprecated: true
components:
  schemas:
    RelevantPagesRequest:
      properties:
        query:
          type: string
          title: Query
          description: The search query
        metadata_filter:
          anyOf:
            - type: object
            - type: 'null'
          title: Metadata Filter
          description: Optional metadata filters using MongoDB-like query syntax
        created_at_filter:
          anyOf:
            - type: object
            - type: 'null'
          title: Created At Filter
          description: >-
            Filter by created_at database field. Supports operators: $eq, $ne,
            $gt, $lt, $gte, $lte, $in, $nin. Use ISO date format (e.g.,
            '2024-01-01T00:00:00')
        updated_at_filter:
          anyOf:
            - type: object
            - type: 'null'
          title: Updated At Filter
          description: >-
            Filter by updated_at database field. Supports operators: $eq, $ne,
            $gt, $lt, $gte, $lte, $in, $nin. Use ISO date format (e.g.,
            '2024-01-01T00:00:00')
        top_k:
          type: integer
          maximum: 1000
          minimum: 1
          title: Top K
          description: Number of results to return
          default: 5
        optimize_metadata:
          type: boolean
          title: Optimize Metadata
          description: If True, optimize the metadata filter based on the query
          default: false
        optimize_query:
          type: boolean
          title: Optimize Query
          description: >-
            If True, optimize the query by removing parts covered by metadata
            filter
          default: false
      type: object
      required:
        - query
      title: RelevantPagesRequest
      example:
        metadata_filter:
          $and:
            - year: '2023'
            - category:
                $in:
                  - finance
                  - earnings
        optimize_metadata: true
        optimize_query: true
        query: Find information about revenue growth
        top_k: 5
    RelevantPagesResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        data:
          allOf:
            - $ref: '#/components/schemas/RelevantPagesResponseData'
          description: Response data
        error:
          anyOf:
            - $ref: '#/components/schemas/ErrorDetail'
            - type: 'null'
        meta:
          $ref: '#/components/schemas/MetaData'
      type: object
      required:
        - data
      title: RelevantPagesResponse
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Error message
        error_code:
          type: string
          title: Error Code
          description: Error code identifier
        details:
          anyOf:
            - items:
                type: object
              type: array
            - type: 'null'
          title: Details
          description: Additional error details
      type: object
      required:
        - message
        - error_code
      title: ErrorDetail
      description: Schema for API error responses.
      example:
        error_code: RESOURCE_NOT_FOUND
        message: Resource not found
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    RelevantPagesResponseData:
      properties:
        pages:
          items:
            $ref: '#/components/schemas/RelevantPage'
          type: array
          title: Pages
        optimized_query:
          anyOf:
            - type: string
            - type: 'null'
          title: Optimized Query
          description: The query after optimization, if optimization was requested
        optimized_metadata:
          anyOf:
            - type: object
            - type: 'null'
          title: Optimized Metadata
          description: >-
            The metadata filter after optimization, if optimization was
            requested
      type: object
      required:
        - pages
      title: RelevantPagesResponseData
    MetaData:
      properties:
        timestamp:
          type: string
          format: date-time
          title: Timestamp
        version:
          type: string
          title: Version
          default: '1.0'
      type: object
      title: MetaData
      description: Metadata for API responses
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    RelevantPage:
      properties:
        document_id:
          type: integer
          title: Document Id
          description: Document identifier
        page_number:
          type: integer
          title: Page Number
          description: Page number
        content:
          type: string
          title: Content
          description: Page content
        score:
          type: number
          title: Score
          description: Relevance score
        document_metadata:
          type: object
          title: Document Metadata
          description: Document metadata
      type: object
      required:
        - document_id
        - page_number
        - content
        - score
        - document_metadata
      title: RelevantPage
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````