{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/ConversationalSearchResult",
  "title": "ConversationalSearchResult",
  "type": "object",
  "properties": {
    "facet_counts": {
      "type": "array",
      "description": "Facet counts from the underlying search.",
      "items": {
        "type": "object"
      }
    },
    "found": {
      "type": "integer",
      "description": "Total number of matching documents."
    },
    "search_time_ms": {
      "type": "integer",
      "description": "Time taken for the search in milliseconds."
    },
    "hits": {
      "type": "array",
      "description": "Search result hits used as context for the answer.",
      "items": {
        "type": "object",
        "properties": {
          "document": {
            "type": "object",
            "description": "The matched document."
          },
          "highlights": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "text_match": {
            "type": "integer",
            "format": "int64"
          }
        }
      }
    },
    "conversation": {
      "type": "object",
      "description": "Conversational response from the LLM.",
      "required": [
        "answer",
        "conversation_id"
      ],
      "properties": {
        "answer": {
          "type": "string",
          "description": "Natural language answer generated by the LLM based on the search results context."
        },
        "conversation_history": {
          "type": "array",
          "description": "History of messages in the conversation.",
          "items": {
            "type": "object",
            "properties": {
              "role": {
                "type": "string",
                "description": "Role of the message sender (user, assistant, system)."
              },
              "content": {
                "type": "string",
                "description": "Content of the message."
              }
            }
          }
        },
        "conversation_id": {
          "type": "string",
          "description": "Unique ID for the conversation, used for follow-up queries."
        }
      }
    }
  }
}