---
openapi: 3.0.0
tags:
  - name: "schema"
  - name: "query"
  - name: "data"

security:
  - ApiKeyAuth: []

paths:
  /api/v1/schema:
    get:
      tags:
        - "schema"
      description: "Return the schema that is provisioned at the moment."
      operationId: "schema"
      responses:
        200:
          description: "The current active schema"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserDefinedDatabaseSchema"
    put:
      tags:
        - "schema"
      description: "Initialize the database with a new schema."
      operationId: "schema"
      requestBody:
        description: "The aito schema definition"
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UserDefinedDatabaseSchema"
      responses:
        200:
          description: "The current active schema"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserDefinedDatabaseSchema"
    delete:
      tags:
        - "schema"
      description: "Delete the entire schema and drop the stored data."
      operationId: "schema"
      responses:
        200:
          description: "The summary of deletion"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeleteSchemaResponse"

  /api/v1/schema/{table}:
    get:
      tags:
        - "schema"
      description: "Return the schema of the specified table."
      operationId: "schema"
      parameters:
        - $ref: "#/components/parameters/Table"
      responses:
        200:
          description: "The current schema of the table"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserDefinedTableSchema"
    put:
      tags:
        - "schema"
      description: "Add the specified table to the schema. **NOTE**: If a table with the same name
      exists in the database, the operation deletes all data in this table and updates the table with the
      specified schema."
      operationId: "schema"
      parameters:
        - $ref: "#/components/parameters/Table"
      requestBody:
        description: "The new schema of the table"
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UserDefinedTableSchema"
      responses:
        200:
          description: "The current schema of the table"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserDefinedTableSchema"
    delete:
      tags:
        - "schema"
      description: "Deletes the specified table from the database."
      operationId: "schema"
      parameters:
        - $ref: "#/components/parameters/Table"
      responses:
        200:
          description: "The summary of deletion"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeleteSchemaResponse"

  /api/v1/schema/{table}/{column}:
    get:
      tags:
        - "schema"
      description: "Return the schema of the specified column."
      operationId: "schema"
      parameters:
        - $ref: "#/components/parameters/Table"
        - $ref: "#/components/parameters/Column"
      responses:
        200:
          description: "The current schema of the column"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ColumnType"
    put:
      tags:
        - "schema"
      description: "Add or replace the specified column using the given schema."
      operationId: "schema"
      parameters:
        - $ref: "#/components/parameters/Table"
        - $ref: "#/components/parameters/Column"
      requestBody:
        description: "The schema of the column"
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/NewColumnType"
      responses:
        200:
          description: "The schema of the column"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ColumnType"
    delete:
      tags:
        - "schema"
      description: "Delete the specified column from a table."
      operationId: "schema"
      parameters:
        - $ref: "#/components/parameters/Table"
        - $ref: "#/components/parameters/Column"
      responses:
        200:
          description: "The summary of deletion"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeleteSchemaResponse"

  /api/v1/schema/_rename:
    post:
      tags:
        - schema
      operationId: rename_table
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RenameTableOperation"
      responses:
        200:
          description: "Rename Table results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EmptyDocument"
        400:
          description: Invalid request body

  /api/v1/schema/_copy:
    post:
      tags:
        - schema
      operationId: copy_table
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CopyTableOperation"
      responses:
        200:
          description: "Copy Table results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EmptyDocument"
        400:
          description: Invalid request body

  /api/v1/data/{table}:
    post:
      tags:
        - "data"
      description: "Insert a single data entry intp the specified table."
      parameters:
        - $ref: "#/components/parameters/Table"
      requestBody:
        required: true
        description: "Any object which is valid according to the provisioned schema"
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UserDefinedObjectInternalWrapper"

      responses:
        200:
          description: "The inserted entry"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserDefinedObjectInternalWrapper"

        400:
          description: "Invalid request body"

  /api/v1/data/{table}/batch:
    post:
      tags:
        - "data"
      description: "Insert a batch of data entries into the specfied table. The batch is assumed to be a JSON
      array of valid entries according to the provisioned schema. ***NOTE***: Batch API supports maximum
      payloads of 10MB."
      parameters:
        - $ref: "#/components/parameters/Table"
      requestBody:
        required: true
        description: "An array of objects which are valid according to the provisioned schema"
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: "#/components/schemas/UserDefinedObject"
      responses:
        200:
          description: "Summary of the inserted entries"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchImportResponse"
        400:
          description: "Invalid request body"

  /api/v1/data/{table}/optimize:
    post:
      tags:
        - data
      summary: optimize optimizes the database by rewriting it as a single segment.
      requestBody:
        required: true
        description: An empty object
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OptimizeOperation"
      responses:
        200:
          description: "An empty object"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OptimizeOperationResponse"
        400:
          description: Invalid request body

  /api/v1/data/{table}/file:
    post:
      tags:
        - "data"
      description: "The first step of inserting data entries into the specified table using file-upload.

      The operation returns a signed S3-URL and a method so that one can upload the file using the accepeted
      method. ***NOTE***: The file must be in gzip compressed [ndjson](http://ndjson.org/) format.

      The operation also returns an id that will be used when triggering file processing
      [See step 2](#/api/v1/data/{table}/file/{uuid})."
      parameters:
        - $ref: "#/components/parameters/Table"
      responses:
        200:
          description: "The details to execute the S3 upload and the job's id"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileUploadStartResponse"
        400:
          description: "Invalid request body"

  /api/v1/data/{table}/file/{uuid}:
    post:
      tags:
        - "data"
      description: "The second step of inserting data entries into the specified table using file-upload
      [See the first step: Initiate file upload](#/api/v1/data/{table}/file).

      The operation starts the processing a previously uploaded file. ***NOTE***: The specified id must match
      the job id from the previous file upload initiation."
      parameters:
        - $ref: "#/components/parameters/Table"
        - $ref: "#/components/parameters/JobId"
      responses:
        200:
          description: "Processing started status"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileUploadProcessTriggerResponse"
        400:
          description: "Invalid request body"
    get:
      tags:
        - "data"
      description: "Return the current status of the specified file upload job using its id. ***NOTE***: The
      specfied id must match the job id from the previous [file upload initiation](#/api/v1/data/{table}/file)."

      parameters:
        - $ref: "#/components/parameters/Table"
        - $ref: "#/components/parameters/JobId"
      responses:
        200:
          description: "The file processing status"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileUploadProcessStatusResponse"
          400:
            description: "Invalid request body"

  /api/v1/data/_delete:
    post:
      tags:
        - data
      operationId: delete
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeleteOperation"
      responses:
        200:
          description: "Delete results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeleteOperationResponse"
        400:
          description: Invalid request body

  /api/v1/data/_modify:
    post:
      tags:
        - data
      operationId: modify
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AnyModification"
      responses:
        200:
          description: "Modify results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AnyModification"
        400:
          description: Invalid request body

  /api/v1/jobs/{query}:
    post:
      tags:
        - query
      parameters:
        - $ref: "#/components/parameters/Query"
      description: "Create a job for a query"
      responses:
        200:
          description: "Job info"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/JobsResponse"
        400:
          description: Invalid request body

  /api/v1/jobs/:
    get:
      tags:
        - query
      description: "Get status for all jobs"
      responses:
        200:
          description: "Job statuses"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/JobsStatusResponse"
        400:
          description: Invalid request body

  /api/v1/jobs/{uuid}:
    get:
      tags:
        - query
      description: "Get status for a job"
      responses:
        200:
          description: "Job status"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/JobsStatusResponse"
        400:
          description: Invalid request body

  /api/v1/jobs/{uuid}/result:
    get:
      tags:
        - query
      description: "Get result for an evaluate job query"
      responses:
        200:
          description: "Evaluate job result"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EvaluateResponse"
        400:
          description: Invalid request body

  /api/v1/_search:
    post:
      tags:
        - query
      operationId: search
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SearchQuery"
      responses:
        200:
          description: "Search results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DecoratedHits"
        400:
          description: Invalid request body

  /api/v1/_similarity:
    post:
      tags:
        - query
      operationId: similarity
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SimilarityQuery"
      responses:
        200:
          description: "Similarity results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DecoratedHits"
        400:
          description: Invalid request body

  /api/v1/_predict:
    post:
      tags:
        - query
      operationId: predict
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PredictQuery"
      responses:
        200:
          description: "Predict results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DecoratedHits"
        400:
          description: Invalid request body

  /api/v1/_match:
    post:
      tags:
        - query
      operationId: match
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MatchQuery"
      responses:
        200:
          description: "Match results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DecoratedHits"
        400:
          description: Invalid request body

  /api/v1/_recommend:
    post:
      tags:
        - query
      operationId: recommend
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RecommendQuery"
      responses:
        200:
          description: "Recommend results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DecoratedHits"
        400:
          description: Invalid request body

  /api/v1/_relate:
    post:
      tags:
        - query
      operationId: relate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RelateQuery"
      responses:
        200:
          description: "Relate results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DecoratedHits"
        400:
          description: Invalid request body

  /api/v1/_query:
    post:
      tags:
        - query
      operationId: query
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Query"
      responses:
        200:
          description: "Query results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DecoratedHits"
        400:
          description: Invalid request body

  /api/v1/_aggregate:
    post:
      tags:
        - query
      operationId: aggregate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AggregateQuery"
      responses:
        200:
          description: "Aggregate results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DecoratedHits"
        400:
          description: Invalid request body

  /api/v1/_estimate:
    post:
      tags:
        - query
      operationId: estimate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EstimateQuery"
      responses:
        200:
          description: "Estimate results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EstimateResult"
        400:
          description: Invalid request body

  /api/v1/_evaluate:
    post:
      tags:
        - query
      operationId: evaluate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EvaluateQueryBase"
      responses:
        200:
          description: "Evaluate results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EvaluateResponse"
        400:
          description: Invalid request body

  /api/v1/_batch:
    post:
      tags:
        - query
      operationId: batch
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BatchQuery"
      responses:
        200:
          description: "Batch results"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchQueryResults"
        400:
          description: Invalid request body

components:
  parameters:
    Table:
      name: table
      in: path
      required: true
      description: The name of the table to add data to
      schema:
        type: string
    Column:
      name: table
      in: path
      required: true
      description: The name of the column
      schema:
        type: string
    Query:
      name: query
      in: path
      required: true
      description: Any of the Aito query endpoints
      schema:
        type: string
    JobId:
      name: uuid
      in: path
      required: true
      description: The assigned id of the operation
      schema:
        type: string

  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
  schemas:
    # This object is used as a wrapper element in API operations where response or request is a
    # UserDefinedObject, because the API docs generator "inlines" the root type.
    "UserDefinedObjectInternalWrapper":
      type: object
      description: "Any object which is valid according to the database schema."
      oneOf:
        - $ref: "#/components/schemas/UserDefinedObject"

    "UserDefinedDatabaseSchema":
      type: object
      description: |
        "Any schema which is a valid Aito database schema.

        Schema describes the structure of the database in a formal language.
        The Aito schema is a collection of database objects (currently only tables)
        that contains its unique names, fields (or columns), and data types of the fields.
        The schema also contains information to help Aito preprocess your data. For
        example what language a textual data contains.

        The contents of the schema depends on the data that will be inserted into the database."

      required:
        - schema
      example: {
        "schema": {
          "products": {
            "type": "table",
            "columns": {
              "id": { "type": "Int" },
              "name": { "type": "String" },
              "price": { "type": "Decimal" },
              "description": { "type": "Text", "analyzer": "English" }
            }
          }
        }
      }
      properties:
        schema:
          type: object
          description: "Database tables. Each key-value pair is a table name and the table schema."
          properties:
            "<yourTableName>":
              $ref: "#/components/schemas/UserDefinedTableSchema"

    "UserDefinedTableSchema":
      type: object
      description: |
        "Any schema which is a valid Aito table schema.

        Table schema describes the structure of the table in a formal language.
        The schema describes all fields (or columns), data types of the fields, and information
        to help Aito preprocess your data. For example what language a textual data contains.

        The contents of the schema depends on the data that will be inserted into the database."
      example: {
        "type": "table",
        "columns": {
          "id": { "type": "Int", "nullable": false },
          "name": { "type": "String", "nullable": false },
          "price": { "type": "Decimal", "nullable": false },
          "description": { "type": "Text", "nullable": false, "analyzer": "English" }
        }
      }
      properties:
        type:
          type: string
          description: "Type of the database schema item. Currently only \"table\" is accepted."
          enum: ["table"]
        columns:
          type: object
          description: "Table columns. Each key-value pair is a column name and the column type."
          properties:
            "<yourColumnName>":
              $ref: "#/components/schemas/ColumnType"

    "ColumnType":
      type: object
      description: |
        "Type of the column.

        Describes an individual field (or column), the type, and information
        to help Aito preprocess your data. For example what language a textual data contains."
      example: { "type": "Int", "nullable": false }
      examples:
        - { "type": "int", "nullable": false }
        - { "type": "string", "nullable": false }
        - { "type": "decimal", "nullable": false }
        - { "type": "text", "nullable": false, "analyzer": "english" }
        - { "type": "json", "nullable": true }
        - { "type": "Int[]" }
        - { "type": "String[]", "nullable": true }
      oneOf:
        - $ref: "#/components/schemas/IntType"
        - $ref: "#/components/schemas/DecimalType"
        - $ref: "#/components/schemas/TextType"
        - $ref: "#/components/schemas/StringType"
        - $ref: "#/components/schemas/BooleanType"
        - $ref: "#/components/schemas/JsonType"
        - $ref: "#/components/schemas/ArrayType"
      discriminator:
        propertyName: "type"
        mapping:
          int: "#/components/schemas/IntType"
          decimal: "#/components/schemas/DecimalType"
          text: "#/components/schemas/TextType"
          string: "#/components/schemas/StringType"
          boolean: "#/components/schemas/BooleanType"
          json: "#/components/schemas/JsonType"
          "Int[]": "#/components/schemas/ArrayType"
          "Long[]": "#/components/schemas/ArrayType"
          "Decimal[]": "#/components/schemas/ArrayType"
          "String[]": "#/components/schemas/ArrayType"
          "Boolean[]": "#/components/schemas/ArrayType"

    "IntType":
      type: object
      description: |
        "Integer column type."
      example: { "type": "Int" }
      examples:
        - { "type": "Int" }
        - { "type": "Int", "link": "users.id" }
      required:
        - type
      properties:
        type:
          description: "Type of the column."
          type: string
          enum: ["int"]
        nullable:
          description: "When true, `null` values are allowed."
          type: boolean
          default: true
        link:
          description: "Path to a column of a linked row."
          type: string
          default: "null"

    "DecimalType":
      type: object
      description: "Decimal column type."
      example: { "type": "Decimal", "nullable": false }
      required:
        - type
      properties:
        type:
          description: "Type of the column."
          type: string
          enum: ["decimal"]
        nullable:
          description: "When true, `null` values are allowed."
          type: boolean
          default: true
        link:
          description: "Path to a column of a linked row."
          type: string
          default: "null"

    "BooleanType":
      type: object
      description: |
        "Boolean column type.
        When column is a boolean, the only accepted values are `true` and `false`."
      example: { "type": "boolean" }
      required:
        - type
      properties:
        type:
          description: "Type of the column."
          type: string
          enum: ["boolean"]
        nullable:
          description: "When true, `null` values are allowed."
          type: boolean
          default: true
        link:
          description: "Path to a column of a linked row."
          type: string
          default: "null"

    "StringType":
      type: object
      description: |
        "String column type.
        The string data type is a primitive version of the Text type.
        The value is turned into a single feature. For example `"lazy black cat"` becomes 1
        feature: `"lazy black cat"`."
      example: { "type": "String", "nullable": false }
      examples:
        - { "type": "String", "nullable": false }
        - { "type": "String", "link": "messages.id" }
      required:
        - type
      properties:
        type:
          description: "Type of the column."
          type: string
          enum: ["string"]
        nullable:
          description: "When true, `null` values are allowed."
          type: boolean
          default: true
        link:
          description: "Path to a column of a linked row."
          type: string
          default: "null"

    "TextType":
      type: object
      description: |
        "Text column type.

        The text data type allows smarter textual analysis. Aito extracts features of the given text
        contents with the configurable `analyzer`.

        Supported analyzers:
        * `"Whitespace"` Extracts features by white space splitting.
            *"lazy black cat"* would be turned into 3 features: *"lazy"*, *"black"*, *"cat"*.
        * `"English"` Extracts features by English stemming.
            *"aito database"* would be turned into 2 features: *"aito"*, *"databas"*.
        * `"Finnish"`
        * `"Swedish"`
        * `"German"`"
      example: { "type": "Text", "analyzer": "English", "nullable": false }
      required:
        - type
      properties:
        type:
          description: "Type of the column."
          type: string
          enum: ["text"]
        analyzer:
          $ref: "#/components/schemas/Analyzer"
        nullable:
          description: "When true, `null` values are allowed."
          type: boolean
          default: true
        link:
          description: "Path to a column of a linked row."
          type: string
          default: "null"
    "NewColumnType":
      type: object
      allOf:
        - $ref: "#/components/schemas/ColumnType"
        - type: object
          properties:
            value:
              description: "Value that existing rows get.
              Optional if the column is nullable or the table is empty."
              nullable: true
              oneOf:
                - type: integer
                - type: number
                - type: boolean
                - type: "null"
                - type: string

    "JsonType":
      type: object
      description: |
        "Json column type.
        The json data type can be any atomic JSON value, object, array or nested structure.
        The json value is turned into a single feature. For example `{"list":[1, 2], "value":true}` becomes 1
        feature: `{"list":[1, 2], "value":true}`."
      example: { "type": "Json", "nullable": false }
      examples:
        - { "type": "Json", "nullable": true }
      required:
        - type
      properties:
        type:
          description: "Type of the column."
          type: string
          enum: ["json"]
        nullable:
          description: "When true, `null` values are allowed."
          type: boolean
          default: true
        link:
          description: "Path to a column of a linked row."
          type: string
          default: "null"

    "ArrayType":
      type: object
      description: |
        "Array column type.
        Arrays contain ordered lists of primitive values of a single type.
        Supported item types: Int (Int[]), Long (Long[]), Decimal (Decimal[]), Boolean (Boolean[]), String (String[]).
        Arrays are useful for storing multi-valued attributes like tags, categories, or feature vectors."
      example: { "type": "Int[]", "nullable": false }
      examples:
        - { "type": "Int[]" }
        - { "type": "String[]", "nullable": true }
        - { "type": "Decimal[]" }
        - { "type": "Boolean[]" }
      required:
        - type
      properties:
        type:
          description: "Type of the column. Use Type[] syntax for arrays, e.g., Int[], String[]."
          type: string
          enum: ["Int[]", "Long[]", "Decimal[]", "String[]", "Boolean[]"]
        nullable:
          description: "When true, `null` values are allowed for the entire array."
          type: boolean
          default: true

    "FileUploadProcessTriggerResponse":
      description: "Processing started status."
      type: object
      required:
        - id
        - status
      properties:
        id:
          type: string
          description: "The id of the operation. Should match the one in the url parameter."
        status:
          type: string
          enum: ["started", "inprogress", "finished"]
          description: "Textual description of the job."

    "FileUploadProcessStatusResponse":
      description: "The file processing status."
      type: object
      required:
        - status
        - errors
      properties:
        status:
          type: object
          required:
            - finished
            - completedCount
            - lastSuccessfulElement
            - finishedAt
            - startedAt
            - thoughput
            - totalDuration
            - totalDurationMs
          properties:
            totalDurationMs:
              type: number
              description: "Total duration of the file processing elapsed"
            totalDuration:
              type: string
              description: "Total duration of the file processing elapsed as human readable units"
            throughput:
              type: string
              description: "Throughput of lines in human readable units"
            startedAt:
              type: string
              format: date-time
              description: "When the file processing was started"
            finishedAt:
              type: string
              format: date-time
              description: "When the file processing was finished"
            finished:
              type: boolean
              description: "Is the job finished or not"
            completedCount:
              type: integer
              description: "The number of lines completed so far"
            lastSuccessfulElement:
              $ref: "#/components/schemas/UserDefinedObject"
        errors:
          type: object
          required:
            - message
          properties:
            message:
              type: string
              description: "Human consumable description."
            rows:
              type: array
              items:
                $ref: "#/components/schemas/UserDefinedObject"
              description: "Array of failing elements. The number of returned elements is restricted."

    "DeleteSchemaResponse":
      description: |
        "Deleted tables."
      type: object
      required:
        - deleted
      example: { "deleted": ["products"] }
      properties:
        deleted:
          type: array
          items:
            type: string
          description: "Array of table names deleted."

    "BatchImportResponse":
      description: |
        "An array of inserted entries."
      type: object
      required:
        - entries
        - status
      properties:
        entries:
          type: integer
          description: "How many entries were inserted."
        status:
          type: string
          description: "Status text"

    "FileUploadStartResponse":
      description: |
        "To be clarified."
      type: object
      required:
        - id
        - url
        - method
        - expires
      properties:
        id:
          type: string
          format: uuid
          description: "The uuid of the file upload session"
        url:
          type: string
          description: "The presigned S3 url where to push the data"
        method:
          type: string
          description: "The http method used for uploading to S3"
        expires:
          type: string
          format: date-time
          description: "Defines when the presigned upload link expires"
    "Analyzer":
      oneOf:
        - $ref: "#/components/schemas/DelimiterAnalyzer"
        - $ref: "#/components/schemas/CharNGramAnalyzer"
        - $ref: "#/components/schemas/LanguageAnalyzer"
        - $ref: "#/components/schemas/TokenNGramAnalyzer"
        - $ref: "#/components/schemas/AliasAnalyzer"
      examples:
        - "standard"
        - "whitespace"
        - "english"
        - "en"
        - { "type": "delimiter", "delimiter": "," }
        - { "type": "language", "language": "en" }
        - { "type": "char-ngram", "minGram": 2, "maxGram": 3 }
        - { "type": "token-ngram", "source": "english", "minGram": 1, "maxGram": 2 }
    "DelimiterAnalyzer":
      type: object
      required:
        - type
        - delimiter
      examples:
        - { "type": "delimiter", "delimiter": "," }
        - { "type": "delimiter", "delimiter": "\n", "trimWhitespace": true }
      properties:
        type:
          description: "Type of the analyzer."
          type: string
          enum: ["delimiter"]
        delimiter:
          type: string
          description: "The delimiter"
        "trimWhitespace":
          description: "Trims leading and trailing whitespace of the features"
          type: boolean
          default: true
    "CharNGramAnalyzer":
      type: object
      required:
        - type
        - minGram
        - maxGram
      example: { "type": "char-ngram", "minGram": 2, "maxGram": 3 }
      properties:
        type:
          description: "Type of the analyzer."
          type: string
          enum: ["char-ngram"]
        minGram:
          description: "The minimum length of characters in a feature."
          type: integer
          format: int32
        maxGram:
          description: "The maximum length of characters in a feature."
          type: integer
          format: int32
    "LanguageAnalyzer":
      type: object
      required:
        - type
        - language
      examples:
        - { "type": "language", "language": "en" }
        - { "type": "language", "language": "english", "useDefaultStopWords": true, "customStopWords": ["flower"], "customKeyWords": ["animal"] }
      properties:
        type:
          description: "Type of the analyzer."
          type: string
          enum: ["language"]
        language:
          description: "Name or code of the language."
          type: string
        useDefaultStopWords:
          description: "Use the language default stopwords."
          type: boolean
          default: false
        customStopWords:
          description: "List of words that will be filtered."
          type: array
          default: []
          items:
            type: string
        customKeyWords:
          description: "List of words that will not be featurizerd."
          type: array
          default: []
          items:
            type: string
    "TokenNGramAnalyzer":
      type: object
      required:
        - type
        - source
        - minGram
        - maxGram
      examples:
        - { "type": "token-ngram", "source": "english", "minGram": 1, "maxGram": 2 }
        - { "type": "token-ngram", "source": { "type": "delimiter", "delimiter": "," }, "minGram": 1, "maxGram": 3, "tokenSeparator": "_" }
      properties:
        type:
          description: "Type of the analyzer."
          type: string
          enum: ["token-ngram"]
        source:
          description: "Source analyzer to generate features before being combined into n-grams."
          $ref: "#/components/schemas/Analyzer"
        minGram:
          description: "The minimum number of features to be combined."
          type: integer
          format: int32
        "maxGram":
          description: "The maximum number of features to be combined."
          type: integer
          format: int32
        "tokenSeparator":
          description: "The string used to join the features of the source analyzer."
          type: string
          default: "\" \""
    "AliasAnalyzer":
      type: string
      examples:
        - "standard"
        - "whitespace"
        - "english"
        - "en"
    "JobsResponse":
      type: object
      properties:
        id:
          description: |
            JobID.
          type: string
        parameters:
          description: |
            Empty for the query API endpoints.
          type: object
          format: int64
        path:
          description: |
            The query path used.
          type: string
        startedAt:
          description: |
            When the job was started.
          format: date-time
          type: string
    "JobsStatusResponse":
      type: object
      properties:
        expiresAt:
          description: |
            Job result will not be available after the date.
          format: date-time
          type: string
        finishedAt:
          description: |
            Job finished running.
          format: date-time
          type: string
        id:
          description: |
            JobID.
          type: string
        parameters:
          description: |
            Empty for the query API endpoints.
          type: object
        path:
          description: |
            The query path used.
          type: string
        startedAt:
          description: |
            When the job was started.
          format: date-time
          type: string

    "OperationsWrapper":
      type: object
      example: {
        "operations": [{
          "set": {
            "stock": 95
          },
          "update": "inventory",
          "where": {
            "product_id": 5
          }
        }, {
          "insert": {
            "product_id": 5,
            "quantity": 5
          },
          "into": "orders"
        }, {
          "insert": {
            "amount": 100,
            "type": "purchase"
          },
          "into": "transactions"
        }]
      }
      required:
        - "operations"
      properties:
        "operations":
          example: [{
            "set": {
              "stock": 95
            },
            "update": "inventory",
            "where": {
              "product_id": 5
            }
          }, {
            "insert": {
              "product_id": 5,
              "quantity": 5
            },
            "into": "orders"
          }, {
            "insert": {
              "amount": 100,
              "type": "purchase"
            },
            "into": "transactions"
          }]
          type: array
          items:
            $ref: "#/components/schemas/AnyModification"
          description: List of modification operations to execute atomically
    "RelateOrderBy":
      example: {
        "$desc": "info.miTrue"
      }
      examples:
        - {
          "$desc": "info.miTrue"
        }
        - {
          "$asc": "lift"
        }
      oneOf:
        - $ref: "#/components/schemas/DescRelate"
        - $ref: "#/components/schemas/AscRelate"
        - type: string
    "WeightedAverageExplanation":
      example: {
        "components": [{
          "value": {
            "name": "Neighbor value: 0.165 (original: 0.17)",
            "type": "neighbor",
            "value": 0.165
          },
          "weight": 1.0
        }, {
          "value": {
            "name": "Neighbor value: 0.163 (original: 0.18)",
            "type": "neighbor",
            "value": 0.163
          },
          "weight": 1.0
        }],
        "type": "weightedAverage",
        "value": 0.16
      }
      type: object
      required:
        - type
        - value
        - components
      properties:
        type:
          description: |
            The explanation type: weighted_average.
          enum: ["weightedAverage"]
          type: string
        value:
          description: |
            The weighted average score.
          type: number
        components:
          description: |
            The weighted components. Final value = sum(weight[i] * value[i]) / sum(weight[i]).
          type: array
          items:
            type: object
            required:
              - weight
              - value
            properties:
              weight:
                description: |
                  The weight of this component.
                type: number
              value:
                description: |
                  The explanation of this component's value.
                $ref: "#/components/schemas/ScoreExplanation"
    "EvaluateGroupedOperation":
      example: {
        "from": "impressions",
        "goal": {
          "purchase": "true"
        },
        "recommend": "product",
        "where": {
          "product.name": {
            "$get": "query"
          },
          "session.user": {
            "$get": "session.user"
          }
        }
      }
      examples:
        - {
          "from": "impressions",
          "goal": {
            "purchase": "true"
          },
          "recommend": "product",
          "where": {
            "product.name": {
              "$get": "query"
            },
            "session.user": {
              "$get": "session.user"
            }
          }
        }
        - {
          "from": "impressions",
          "get": "product",
          "orderBy": {
            "$p": {
              "purchase": true
            }
          },
          "where": {
            "product.name": {
              "$get": "query"
            },
            "session.user": {
              "$get": "session.user"
            }
          }
        }
      oneOf:
        - $ref: "#/components/schemas/EvaluateMultiGenericQuery"
        - $ref: "#/components/schemas/EvaluateRecommend"
    "SearchQuery":
      type: object
      example: {
        "from": "impressions",
        "limit": 2,
        "offset": 2,
        "orderBy": "product.title",
        "select": ["user.name", "query", "product.title", "click"],
        "where": {
          "customer": 4,
          "query": {
            "$match": "laptop"
          }
        }
      }
      required:
        - "from"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "customer": 4,
            "query": {
              "$match": "laptop"
            }
          }
          $ref: "#/components/schemas/Proposition"
        "orderBy":
          example: "product.title"
          $ref: "#/components/schemas/OrderBy"
        "select":
          example: ["user.name", "query", "product.title", "click"]
          $ref: "#/components/schemas/Projection"
        "offset":
          example: 2
          type: integer
          format: int64
          description: The number of results to skip from the beginning.
          default: 0
        "limit":
          example: 2
          type: integer
          format: int64
          description: The maximum number of results to retrieve.
          default: 10
    "RegressionExplanation":
      example: {
        "operation": "reduction",
        "proposition": {
          "category": "dairy"
        },
        "regressionType": "categorical",
        "residual": null,
        "type": "regression",
        "value": -0.234
      }
      examples:
        - {
          "operation": "reduction",
          "proposition": {
            "category": "dairy"
          },
          "regressionType": "categorical",
          "residual": null,
          "type": "regression",
          "value": -0.234
        }
        - {
          "operation": "reduction",
          "proposition": {
            "sale_price": 20.0
          },
          "regressionType": "linear",
          "residual": 2.427,
          "type": "regression",
          "value": -0.234
        }
      type: object
      required:
        - type
        - proposition
        - value
        - regressionType
        - operation
      properties:
        type:
          description: |
            The explanation type: regression.
          enum: ["regression"]
          type: string
        proposition:
          description: |
            The field-value proposition that triggered this regression adjustment.
          $ref: "#/components/schemas/PropositionExplanation"
        value:
          description: |
            The regression effect/contribution to the score.
          type: number
        regressionType:
          description: |
            The type of regression: 'categorical' (group effects) or 'linear' (OLS).
          type: object
        residual:
          description: |
            For linear regression: the predictor's residual value after its own transformation pipeline.
          type: number
        operation:
          description: |
            The operation: 'reduction' (removing effect) or 'restoration' (adding effect back).
          type: object
    "GetValueExpression":
      example: {"$get": "query"}
      examples:
        - {"$get": "query"}
        - {"$get": "click"}
        - {"$get": "product.title"}
      type: object
      properties:
        $get:
          type: string
    "TestSource":
      type: object
      example: {
        "limit": 100,
        "select": ["query"],
        "where": {
          "$index": {
            "$mod": [5, 1]
          }
        }
      }
      properties:
        "from":
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "$index": {
              "$mod": [5, 1]
            }
          }
          $ref: "#/components/schemas/Proposition"
        "offset":
          type: integer
          format: int64
        "limit":
          example: 100
          type: integer
          format: int64
        "select":
          example: ["query"]
          $ref: "#/components/schemas/Selection"
    "On":
      example: { "$on": { "prop": { "click": true}, "on": { "user.tags": "nyc" } } }
      examples:
        - { "$on": { "prop": { "click": true}, "on": { "user.tags": "nyc" } } }
        - { "$on": [{ "click": true }, { "user.tags": "nyc" }] }
      type: object
      properties:
        $on:
          oneOf:
            - $ref: "#/components/schemas/OnPropositionObject"
            - $ref: "#/components/schemas/OnPropositionArray"
    "Has":
      example: { "$has": "drink" }
      examples:
        - { "$has": "drink" }
        - {
          "from": "products",
          "where": {
            "tags": { "$has": "drink" }
          }
        }
      type: object
      properties:
        $has:
          oneOf:
            - $ref: "#/components/schemas/GetValueExpression"
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: "null"
            - $ref: "#/components/schemas/ArrayValue"
            - $ref: "#/components/schemas/ToString"
            - type: boolean
            - type: string
            - $ref: "#/components/schemas/Json"
    "ProductExplanation":
      example: {
        "factors": [{
          "factors": [{
            "type": "baseLift",
            "value": 31.0
          }],
          "proposition": {
            "id": 3
          },
          "type": "hitPropositionLift",
          "value": 31.0
        }, {
          "field": "price",
          "type": "field",
          "value": 1500.0
        }],
        "type": "product"
      }
      type: object
      required:
        - type
        - factors
      properties:
        type:
          description: |
            The explanation type: product.
          enum: ["product"]
          type: string
        factors:
          description: |
            The explanation of the product score's factors.
          type: array
          items:
            $ref: "#/components/schemas/ScoreExplanation"
    "KnnExplanation":
      type: object
      properties:
        $knn:
          type: object
          properties:
            "k":
              type: integer
              format: int32
            "near":
              type: array
              items:
                $ref: "#/components/schemas/PropositionExplanation"
    "PropositionSet":
      example: "product.tags"
      examples:
        - "product.tags"
        - "query"
        - "product"
        - "tags"
      oneOf:
        - type: array
          items:
            $ref: "#/components/schemas/PropositionSet"
        - type: string
        - $ref: "#/components/schemas/Proposition"
    "DeleteOperation2":
      type: object
      example: {
        "delete": {
          "id": 4
        },
        "from": "users"
      }
      required:
        - "from"
        - "delete"
      properties:
        "from":
          example: "users"
          type: string
          description: Table to delete from
        "delete":
          example: {
            "id": 4
          }
          $ref: "#/components/schemas/Proposition"
          description: Conditions to match rows for deletion
    "RankProjection":
      example: "$rank"
      type: string
      enum: ["$rank"]
    "AscRelate":
      example: { "$asc": "lift" }
      type: object
      properties:
        $asc:
          type: string
    "FromWhere":
      type: object
      example: {
        "from": "impressions",
        "where": {
          "click": true
        }
      }
      required:
        - "from"
        - "where"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "click": true
          }
          $ref: "#/components/schemas/Proposition"
        "limit":
          type: integer
          format: int64
    "RelateQuery":
      type: object
      example: {
        "from": "impressions",
        "limit": 2,
        "offset": 2,
        "relate": "prevProduct",
        "select": ["related", "condition", "lift", "ps", "fs"],
        "where": {
          "customer": 4,
          "query": "laptop"
        }
      }
      required:
        - "from"
        - "relate"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "customer": 4,
            "query": "laptop"
          }
          $ref: "#/components/schemas/Proposition"
        "relate":
          example: "prevProduct"
          $ref: "#/components/schemas/PropositionSet"
        "orderBy":
          $ref: "#/components/schemas/RelateOrderBy"
        "select":
          example: ["related", "condition", "lift", "ps", "fs"]
          $ref: "#/components/schemas/Selection"
        "offset":
          example: 2
          type: integer
          format: int64
          description: The number of results to skip from the beginning.
          default: 0
        "limit":
          example: 2
          type: integer
          format: int64
          description: The maximum number of results to retrieve.
          default: 10
    "AscGenericQuery":
      example: { "$asc": "price" }
      examples:
        - { "$asc": "price" }
        - { "$asc": "product.price" }
        - { "$asc": { "$multiply": ["product.price", "$p"] } }
      type: object
      properties:
        $asc:
          $ref: "#/components/schemas/Value"
    "OptimizeOperation2":
      type: object
      example: {
        "optimize": "users"
      }
      required:
        - "optimize"
      properties:
        "optimize":
          example: "users"
          type: string
          description: Table to optimize
    "FromTablemodify":
      example: "impressions"
      examples:
        - "impressions"
        - "products"
        - "customers"
        - "messages"
      type: string
    "FieldExplanation":
      example: {
        "field": "price",
        "type": "field",
        "value": 1500.0
      }
      type: object
      required:
        - type
        - field
        - value
      properties:
        type:
          description: |
            The explanation type: field.
          enum: ["field"]
          type: string
        field:
          description: |
            The name or feature of the field.
          type: string
        value:
          description: |
            The score value.
          type: number
    "UpdateOperation":
      type: object
      example: {
        "set": {
          "archived": true
        },
        "update": "users",
        "where": {
          "status": "inactive"
        }
      }
      required:
        - "update"
        - "set"
        - "where"
      properties:
        "update":
          example: "users"
          type: string
          description: Table to update
        "set":
          example: {
            "archived": true
          }
          type: object
          description: Fields to update with new values (JSON object mapping field names to new values)
        "where":
          example: {
            "status": "inactive"
          }
          $ref: "#/components/schemas/Proposition"
          description: Conditions to match rows for update
        "upsert":
          type: boolean
          description: If true, insert if no match found (upsert)
          default: false
    "MaxScore":
      example: {
        "$max": {
          "$context": "score"
        }
      }

      type: object
      properties:
        $max:
          $ref: "#/components/schemas/ContextValueQuery"
    "UserDefinedObject":
      example: {
        "name": "My product",
        "price": 172.19
      }
      type: object
    "ProbabilityScore":
      example: { "$p": "tags" }
      examples:
        - { "$p": "tags" }
        - { "$p": ["tags", "title"] }
        - {
          "$p": {
            "$context": {
              "click": true
            }
          }
        }

        - {
          "from": "impressions",
          "where": {
            "product.title": {
              "$match": "iphone"
            }
          },
          "get": "product",
          "orderBy": {
            "$p": "tags"
          }
        }

        - {
          "from": "impressions",
          "where": {
            "product.title": {
              "$match": "iphone"
            }
          },
          "get": "product",
          "orderBy": {
            "$p": [
              "tags",
              "title"
            ]
          }
        }

        - {
          "from": "impressions",
          "where": {
            "product.title": {
              "$match": "iphone"
            }
          },
          "get": "product",
          "orderBy": {
            "$p": {
              "$context": {
                "click": true
              }
            }
          }
        }

      type: object
      properties:
        $p:
          $ref: "#/components/schemas/PropositionSet"
    "GteExplanation":
      type: object
      properties:
        $gte:
          oneOf:
            - $ref: "#/components/schemas/IntArray"
            - $ref: "#/components/schemas/LongArray"
            - $ref: "#/components/schemas/DecimalArray"
            - $ref: "#/components/schemas/StringArray"
            - $ref: "#/components/schemas/BooleanArray"
            - type: object
            - type: object
            - type: object
            - type: object
            - type: object
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: boolean
            - type: "null"
            - type: string
            - type: object
    "NnPropositionArray":
      example: [{
        "tags": "laptop"
      }]
      type: array
      minItems: 2
      maxItems: 2
      items:
        oneOf:
          - oneOf:
              - $ref: "#/components/schemas/Proposition"
              - $ref: "#/components/schemas/PrimitiveProposition"
          - type: number
    "Hit":
      example: { "$hit": "price" }
      examples:
        - { "$hit": "price" }
        - { "$hit": "$similarity" }
        - {
          "from": "impressions",
          "where": {
            "product.title": { "$match": "iphone" }
          },
          "get": "product",
          "orderBy": {
            "$multiply": [
              { "$hit": "$similarity" },
              { "$hit": "price" }
            ]
          }
        }

      type: object
      properties:
        $hit:
          $ref: "#/components/schemas/Score"
    "NeighborContextExplanation":
      example: {
        "adjustments": {
          "terms": [{
            "type": "original_value",
            "value": 2.3
          }, {
            "type": "adjustment",
            "value": 0.1
          }],
          "type": "sum"
        },
        "hitScore": 0.95,
        "instance": {
          "brand": "Premium",
          "category": "Books"
        },
        "original": 2.3,
        "position": "row_123",
        "type": "neighborContext",
        "value": 2.4
      }
      type: object
      required:
        - type
        - value
        - original
        - adjustments
        - instance
        - position
      properties:
        type:
          description: |
            The explanation type: neighbor_context (K-NN neighbor with instance data).
          enum: ["neighborContext"]
          type: string
        value:
          description: |
            The adjusted neighbor value.
          type: number
        original:
          description: |
            The original neighbor value before adjustments.
          type: number
        adjustments:
          description: |
            Explanation of how original value was adjusted.
          $ref: "#/components/schemas/ScoreExplanation"
        instance:
          description: |
            The instance features for this neighbor.
          $ref: "#/components/schemas/ResponseHit"
        hitScore:
          description: |
            Similarity/hit score for this neighbor.
          type: number
        position:
          description: |
            Position/ID reference for this neighbor.
          type: string
    "ExponentPropositionObject":
      type: object
      example: {
        "base": "width",
        "exponent": 2
      }
      required:
        - "base"
        - "exponent"
      properties:
        "base":
          example: "width"
          $ref: "#/components/schemas/Score"
        "exponent":
          example: 2
          $ref: "#/components/schemas/Score"
    "SubtractionExplanation":
      example: {
        "minuend": {
          "field": "price",
          "type": "field",
          "value": 119.50
        },
        "subtrahend": {
          "field": "cost",
          "type": "field",
          "value": 100.5
        },
        "type": "subtraction"
      }
      type: object
      required:
        - type
        - minuend
        - subtrahend
      properties:
        type:
          description: |
            The explanation type: divide.
          enum: ["subtraction"]
          type: string
        minuend:
          description: |
            The subtracted value.
          $ref: "#/components/schemas/ScoreExplanation"
        subtrahend:
          description: |
            The subtraction value.
          $ref: "#/components/schemas/ScoreExplanation"
    "ModPropositionObject":
      type: object
      example: {
        "divisor": 2,
        "remainder": 0
      }
      required:
        - "divisor"
        - "remainder"
      properties:
        "divisor":
          example: 2
          type: integer
          format: int64
        "remainder":
          example: 0
          type: integer
          format: int64
    "EvaluateNumericOperation":
      type: object
      example: {
        "estimate": "price",
        "from": "products",
        "where": {
          "category": {
            "$get": "category"
          }
        }
      }
      required:
        - "from"
        - "estimate"
      properties:
        "from":
          example: "products"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "category": {
              "$get": "category"
            }
          }
          $ref: "#/components/schemas/Proposition"
        "estimate":
          example: "price"
          type: string
        "basedOn":
          $ref: "#/components/schemas/PropositionSet"
    "PField":
      example: "$p"
      type: string
      enum: ["$p"]
    "EvaluateEstimateQuery":
      type: object
      example: {
        "evaluate": {
          "estimate": "price",
          "from": "products",
          "where": {
            "category": {
              "$get": "category"
            }
          }
        },
        "select": ["rmse", "mae", "r2", "n"],
        "test": {
          "$index": {
            "$mod": [10, 1]
          }
        }
      }
      required:
        - "evaluate"
      properties:
        "train":
          $ref: "#/components/schemas/Proposition"
        "test":
          example: {
            "$index": {
              "$mod": [10, 1]
            }
          }
          $ref: "#/components/schemas/Proposition"
        "testSource":
          $ref: "#/components/schemas/TestSource"
        "select":
          example: ["rmse", "mae", "r2", "n"]
          $ref: "#/components/schemas/Selection"
        "evaluate":
          example: {
            "estimate": "price",
            "from": "products",
            "where": {
              "category": {
                "$get": "category"
              }
            }
          }
          $ref: "#/components/schemas/EvaluateNumericOperation"
    "ResponseHit":
      example: {
        "name": "My product",
        "price": 172.19
      }
      examples:
        - {
          "name": "My product",
          "price": 172.19
        }
        - {
          "$score": 0.22350516297675496,
          "$value": "coffee",
          "$why": {
            "factors": [{
              "factors": [{
                "proposition": {
                  "name": {
                    "$has": "coffee"
                  }
                },
                "type": "relatedPropositionLift",
                "value": 8.45603245079726
              }],
              "proposition": "coffee",
              "type": "hitPropositionLift",
              "value": 8.45603245079726
            }],
            "type": "product"
          }
        }
      oneOf:
        - $ref: "#/components/schemas/UserDefinedObject"
        - $ref: "#/components/schemas/PropositionExplanation"
        - type: object
        - $ref: "#/components/schemas/ScoreExplanation"
    "OrExplanation":
      type: object
      properties:
        $or:
          type: array
          items:
            $ref: "#/components/schemas/PropositionExplanation"
    "ToString":
      example: {"$toString": 4}
      type: object
      properties:
        $toString:
          oneOf:
            - $ref: "#/components/schemas/GetValueExpression"
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: "null"
            - $ref: "#/components/schemas/ArrayValue"
            - $ref: "#/components/schemas/ToString"
            - type: boolean
            - type: string
            - $ref: "#/components/schemas/Json"
    "EvaluateQuery":
      type: object
      example: {
        "evaluate": {
          "from": "products",
          "predict": "category",
          "where": {
            "name": {
              "$get": "name"
            }
          }
        },
        "select": ["accuracy", "meanRank", "n"],
        "test": {
          "$index": {
            "$mod": [10, 1]
          }
        }
      }
      required:
        - "evaluate"
      properties:
        "train":
          $ref: "#/components/schemas/Proposition"
        "test":
          example: {
            "$index": {
              "$mod": [10, 1]
            }
          }
          $ref: "#/components/schemas/Proposition"
        "testSource":
          $ref: "#/components/schemas/TestSource"
        "select":
          example: ["accuracy", "meanRank", "n"]
          $ref: "#/components/schemas/Selection"
        "evaluate":
          example: {
            "from": "products",
            "predict": "category",
            "where": {
              "name": {
                "$get": "name"
              }
            }
          }
          $ref: "#/components/schemas/EvaluateOperation"
    "PlainSimilarity":
      example: "$similarity"
      examples:
        - "$similarity"
        - {
          "from": "product",
          "get": "message",
          "orderBy": "$similarity",
          "where": {
            "title": {
              "$match": "iphone"
            }
          }
        }
      type: string
      enum: ["$similarity"]
    "AndExplanation":
      type: object
      properties:
        $and:
          type: array
          items:
            $ref: "#/components/schemas/PropositionExplanation"
    "LogarithmicExplanation":
      example: {
        "inner": {
          "type": "constant",
          "value": 0.173
        },
        "type": "log",
        "value": -1.754
      }
      type: object
      required:
        - type
        - value
        - inner
      properties:
        type:
          description: |
            The explanation type: log (logarithmic transformation).
          enum: ["log"]
          type: string
        value:
          description: |
            The logarithmic score value log(inner).
          type: number
        inner:
          description: |
            The explanation in linear space that gets log-transformed.
          $ref: "#/components/schemas/ScoreExplanation"
    "BooleanArray":
      example: [true, false, true]
      type: array
      items:
        type: boolean
    "ScoreExplanation":
      example: {
        "type": "baseP",
        "value": 0.28
      }
      oneOf:
        - $ref: "#/components/schemas/SumExplanation"
        - $ref: "#/components/schemas/SubtractionExplanation"
        - $ref: "#/components/schemas/ProductExplanation"
        - $ref: "#/components/schemas/DivisionExplanation"
        - $ref: "#/components/schemas/BaseProbabilityExplanation"
        - $ref: "#/components/schemas/RelatedPropositionLiftExplanation"
        - $ref: "#/components/schemas/HitLinkPropositionLiftExplanation"
        - $ref: "#/components/schemas/DecoratedScoreExplanation"
        - $ref: "#/components/schemas/HitPropositionLiftExplanation"
        - $ref: "#/components/schemas/ConstantExplanation"
        - $ref: "#/components/schemas/DefaultValueExplanation"
        - $ref: "#/components/schemas/RegressionExplanation"
        - $ref: "#/components/schemas/NamedExplanation"
        - $ref: "#/components/schemas/BaseLiftExplanation"
        - $ref: "#/components/schemas/PredictExplanation"
        - $ref: "#/components/schemas/ExponentExplanation"
        - $ref: "#/components/schemas/TermFrequencyExplanation"
        - $ref: "#/components/schemas/InverseDocumentFrequencyExplanation"
        - $ref: "#/components/schemas/ExponentialExplanation"
        - $ref: "#/components/schemas/LogarithmicExplanation"
        - $ref: "#/components/schemas/WeightedAverageExplanation"
        - $ref: "#/components/schemas/NeighborContextExplanation"
        - $ref: "#/components/schemas/FieldExplanation"
        - $ref: "#/components/schemas/NoneExplanation"
    "ExponentExplanation":
      example: {
        "base": {
          "type": "idf",
          "value": 1.7551720221592049
        },
        "power": {
          "type": "tf",
          "value": 1.0
        },
        "type": "exponent",
        "value": 1.7551720221592049
      }
      type: object
      required:
        - type
        - value
        - base
        - power
      properties:
        type:
          description: |
            The explanation type: exponent.
          enum: ["exponent"]
          type: string
        value:
          description: |
            The exponent score.
          type: number
        base:
          description: |
            The explanation of the base score element.
          $ref: "#/components/schemas/ScoreExplanation"
        power:
          description: |
            The explanation of the power score element.
          $ref: "#/components/schemas/ScoreExplanation"
    "OptimizeOperationResponse":
      type: object
      example: {
      }
      properties:
    "Get":
      example: "product"
      examples:
        - "product"
        - "user"
        - "text.$feature"
        - "link.field"
        - "link.$feature"
        - "link.text.$feature"
      type: string
    "RecommendQuery":
      type: object
      example: {
        "from": "impressions",
        "goal": {
          "click": true
        },
        "limit": 2,
        "offset": 2,
        "recommend": "product",
        "select": ["title", "description", "price"],
        "where": {
          "customer": 4,
          "query": "laptop"
        }
      }
      required:
        - "from"
        - "recommend"
        - "goal"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "customer": 4,
            "query": "laptop"
          }
          $ref: "#/components/schemas/Proposition"
        "recommend":
          example: "product"
          $ref: "#/components/schemas/Get"
        "basedOn":
          $ref: "#/components/schemas/PropositionSet"
        "goal":
          example: {
            "click": true
          }
          $ref: "#/components/schemas/Goal"
        "select":
          example: ["title", "description", "price"]
          $ref: "#/components/schemas/Projection"
        "offset":
          example: 2
          type: integer
          format: int64
          description: The number of results to skip from the beginning.
          default: 0
        "limit":
          example: 2
          type: integer
          format: int64
          description: The maximum number of results to retrieve.
          default: 10
    "ScoreField":
      example: "$score"
      type: string
      enum: ["$score"]
    "EvaluateGroupedQuery":
      type: object
      example: {
        "evaluate": {
          "from": "impressions",
          "goal": {
            "purchase": "true"
          },
          "recommend": "product",
          "where": {
            "product.name": {
              "$get": "query"
            },
            "session.user": {
              "$get": "session.user"
            }
          }
        },
        "group": "userGroup",
        "select": ["accuracy", "meanRank", "n"],
        "test": {
          "userGroup": {
            "$gte": 5
          }
        }
      }
      required:
        - "group"
        - "evaluate"
      properties:
        "train":
          $ref: "#/components/schemas/Proposition"
        "test":
          example: {
            "userGroup": {
              "$gte": 5
            }
          }
          $ref: "#/components/schemas/Proposition"
        "testSource":
          $ref: "#/components/schemas/TestSource"
        "select":
          example: ["accuracy", "meanRank", "n"]
          $ref: "#/components/schemas/Selection"
        "group":
          example: "userGroup"
          type: string
        "goal":
          $ref: "#/components/schemas/Proposition"
        "evaluate":
          example: {
            "from": "impressions",
            "goal": {
              "purchase": "true"
            },
            "recommend": "product",
            "where": {
              "product.name": {
                "$get": "query"
              },
              "session.user": {
                "$get": "session.user"
              }
            }
          }
          $ref: "#/components/schemas/EvaluateGroupedOperation"
    "IntArray":
      example: [1, 2, 3]
      type: array
      items:
        type: integer
        format: int32
    "EvaluateResponse":
      type: object
      required:
        - n
        - testSamples
        - trainSamples
        - features
        - error
        - baseError
        - accuracy
        - baseAccuracy
        - accuracyGain
        - meanRank
        - baseMeanRank
        - rankGain
        - informationGain
        - mxe
        - h
        - geomMeanP
        - baseGmp
        - geomMeanLift
        - meanNs
        - meanUs
        - meanMs
        - medianNs
        - medianUs
        - medianMs
        - warmingMs
      properties:
        n:
          description: |
            The amount of samples used for testing. Alias for `testSamples`.
          type: integer
          format: int64
        testSamples:
          description: |
            The amount of samples used for testing.
          type: integer
          format: int64
        trainSamples:
          description: |
            The average amount of samples used for training.
          type: number
        features:
          description: |
            The average number of features
          type: number
        error:
          description: |
            Complement of `accuracy` (=`1 - accuracy`).
          type: number
        baseError:
          description: |
            Complement of `baseAccuracy` (=`1 - baseAccuracy`).
          type: number
        accuracy:
          description: |
            The accuracy of predictions.
          type: number
        baseAccuracy:
          description: |
            The simulated accuracy of predictions based on taking the most frequent value. This is not the actual Aito accuracy, but useful to understand how much better results Aito can provide.
          type: number
        accuracyGain:
          description: |
            How much better results Aito was able to provide compared to a naive prediction. `accuracy - baseAccuracy`.
          type: number
        meanRank:
          description: |
            Average rank of the best prediction
          type: number
        baseMeanRank:
          description: |

          type: number
        rankGain:
          description: |
            Improvement of meanRank upon baseMeanRank
          type: number
        informationGain:
          description: |
            A measurement which describes the quality of probabilities (=`h - mxe`).
          type: number
        mxe:
          description: |
            Mean cross entropy
          type: number
        h:
          description: |
            Entropy
          type: number
        geomMeanP:
          description: |
            The mean geometric probability of the predictions
          type: number
        baseGmp:
          description: |
            Base geometric mean probability.
          type: number
        geomMeanLift:
          description: |
            Geometric mean lift. `geomMeanP / baseGmp`
          type: number
        meanNs:
          description: |
            The mean execution time of the queries in nanoseconds.
          type: number
        meanUs:
          description: |
            The mean execution time of the queries in microseconds.
          type: number
        meanMs:
          description: |
            The mean execution time of the queries in milliseconds.
          type: number
        medianNs:
          description: |
            The median execution time of the queries in nanoseconds.
          type: number
        medianUs:
          description: |
            The median execution time of the queries in microseconds.
          type: number
        medianMs:
          description: |
            The median execution time of the queries in milliseconds.
          type: number
        warmingMs:
          description: |
            The time spent for warm-up of indexes and caches for the given query in milliseconds.
          type: number
    "NotExplanation":
      type: object
      properties:
        $not:
          $ref: "#/components/schemas/PropositionExplanation"
    "AnalogyScore":
      example: { "$analogy": { "with": "veronica", "basedOn": "purchases" } }
      examples:
        - { "$analogy": { "with": "veronica", "basedOn": "purchases" } }
        - {
          "from": "products",
          "get": "title",
          "orderBy": {
            "$analogy": {
              "with": "ideapad",
              "basedOn": "tags"
            }
          }
        }

      type: object
      properties:
        $analogy:
          type: object
          properties:
            "with":
              oneOf:
                - $ref: "#/components/schemas/GetValueExpression"
                - type: integer
                  format: int32
                - type: integer
                  format: int64
                - type: number
                - type: "null"
                - $ref: "#/components/schemas/ArrayValue"
                - $ref: "#/components/schemas/ToString"
                - type: boolean
                - type: string
                - $ref: "#/components/schemas/Json"
            "basedOn":
              $ref: "#/components/schemas/PropositionSet"
    "EvaluateMultiGenericQuery":
      type: object
      example: {
        "from": "impressions",
        "get": "product",
        "orderBy": {
          "$p": {
            "purchase": true
          }
        },
        "where": {
          "product.name": {
            "$get": "query"
          },
          "session.user": {
            "$get": "session.user"
          }
        }
      }
      required:
        - "from"
        - "get"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "product.name": {
              "$get": "query"
            },
            "session.user": {
              "$get": "session.user"
            }
          }
          $ref: "#/components/schemas/Proposition"
        "get":
          example: "product"
          $ref: "#/components/schemas/Get"
        "orderBy":
          example: {
            "$p": {
              "purchase": true
            }
          }
          $ref: "#/components/schemas/OrderBy"
        "select":
          $ref: "#/components/schemas/Projection"
        "offset":
          type: integer
          format: int64
        "limit":
          type: integer
          format: int64
    "Numeric":
      example: { "$numeric": 42 }
      examples:
        - { "$numeric": 42 }
        - { "$numeric": 3.14 }
      type: object
      properties:
        $numeric:
          oneOf:
            - $ref: "#/components/schemas/GetValueExpression"
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: "null"
    "LtExplanation":
      type: object
      properties:
        $lt:
          oneOf:
            - $ref: "#/components/schemas/IntArray"
            - $ref: "#/components/schemas/LongArray"
            - $ref: "#/components/schemas/DecimalArray"
            - $ref: "#/components/schemas/StringArray"
            - $ref: "#/components/schemas/BooleanArray"
            - type: object
            - type: object
            - type: object
            - type: object
            - type: object
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: boolean
            - type: "null"
            - type: string
            - type: object
    "InsertOperation":
      type: object
      example: {
        "insert": {
          "age": 30,
          "name": "Alice"
        },
        "into": "users"
      }
      required:
        - "into"
        - "insert"
      properties:
        "into":
          example: "users"
          type: string
          description: Table to insert into
        "insert":
          example: {
            "age": 30,
            "name": "Alice"
          }
          type: object
          description: Documents to insert (single document or array of documents as JSON)
    "IndexProjection":
      example: "$index"
      type: string
      enum: ["$index"]
    "Divide":
      example: { "$divide": ["cost", 4] }
      type: object
      properties:
        $divide:
          oneOf:
            - type: object
              properties:
                "dividend":
                  $ref: "#/components/schemas/Score"
                "divisor":
                  $ref: "#/components/schemas/Score"
            - type: array
              minItems: 2
              maxItems: 2
              items:
                $ref: "#/components/schemas/Score"
    "EmptyDocument":
      type: object
      required:
      properties:
    "Defined":
      example: { "$defined": true }
      type: object
      properties:
        $defined:
          type: boolean
    "DeleteOperationResponse":
      type: object
      required:
        - total
      properties:
        total:
          description: |
            The number of rows that was deleted
          type: integer
          format: int64
    "Nn":
      example: { "$nn": [{"tags": "laptop" }] }
      examples:
        - { "$nn": [{"tags": "laptop" }] }
        - { "$nn": {"near": {"tags": "laptop" } } }
      type: object
      properties:
        $nn:
          oneOf:
            - $ref: "#/components/schemas/NnPropositionObject"
            - $ref: "#/components/schemas/NnPropositionArray"
    "LongArray":
      example: [1000000000000, 2000000000000]
      type: array
      items:
        type: integer
        format: int64
    "TermFrequencyExplanation":
      example: {
        "type": "tf",
        "value": 1.0
      }
      type: object
      required:
        - type
        - value
      properties:
        type:
          description: |
            The explanation type: tf.
          enum: ["tf"]
          type: string
        value:
          description: |
            The term frequency score.
          type: number
    "LiftScore":
      example: { "$lift": "tags" }
      examples:
        - { "$lift": "tags" }
        - { "$lift": ["tags", "title"] }
        - {
          "$lift": {
            "$context": {
              "click": true
            }
          }
        }

        - {
          "from": "impressions",
          "where": {
            "product.title": {
              "$match": "iphone"
            }
          },
          "get": "product",
          "orderBy": {
            "$lift": "tags"
          }
        }

        - {
          "from": "impressions",
          "where": {
            "product.title": {
              "$match": "iphone"
            }
          },
          "get": "product",
          "orderBy": {
            "$lift": [
              "tags",
              "title"
            ]
          }
        }

        - {
          "from": "impressions",
          "where": {
            "product.title": {
              "$match": "iphone"
            }
          },
          "get": "product",
          "orderBy": {
            "$lift": {
              "$context": {
                "click": true
              }
            }
          }
        }

      type: object
      properties:
        $lift:
          $ref: "#/components/schemas/PropositionSet"
    "And":
      example: { "$and": [{ "$gt": 10 }, { "$lt": 20 }] }
      examples:
        - { "$and": [{ "$gt": 10 }, { "$lt": 20 }] }
        - {
          "from": "products",
          "where": {
            "price": {
              "$and": [
                { "$gt": 1.5 },
                { "$lt": 2.1 }
              ]
            }
          }
        }
      type: object
      properties:
        $and:
          type: array
          items:
            oneOf:
              - $ref: "#/components/schemas/Proposition"
              - $ref: "#/components/schemas/PrimitiveProposition"
    "DescRelate":
      example: { "$desc": "info.miTrue" }
      type: object
      properties:
        $desc:
          type: string
    "AggregateProjection":
      example: "price.$mean"
      oneOf:
        - $ref: "#/components/schemas/AggregateList"
        - $ref: "#/components/schemas/AggregateMean"
        - $ref: "#/components/schemas/AggregateSum"
        - $ref: "#/components/schemas/AggregateFrequency"
        - $ref: "#/components/schemas/FrequencyAggregateField"
        - $ref: "#/components/schemas/AggregateField"
        - $ref: "#/components/schemas/NamedAggregateProjection"
    "AggregateField":
      example: "price.$mean"
      examples:
        - "price.$mean"
        - "price.$sum"
      type: string
    "AggregateFrequency":
      example: { "$f": { "click": false } }
      examples:
        - { "$f": { "click": false } }
        - { "$f": { "price": { "$gt": 100 } } }
      type: object
      properties:
        $f:
          $ref: "#/components/schemas/Proposition"
    "NnPropositionObject":
      type: object
      example: {
        "near": {
          "tags": "laptop"
        }
      }
      required:
        - "near"
      properties:
        "near":
          example: {
            "tags": "laptop"
          }
          oneOf:
            - $ref: "#/components/schemas/Proposition"
            - $ref: "#/components/schemas/PrimitiveProposition"
        "threshold":
          type: number
    "Goal":
      example: {
        "purchase": true
      }
      examples:
        - {
          "purchase": true
        }
        - {
          "click": true
        }
      oneOf:
        - $ref: "#/components/schemas/Score"
        - $ref: "#/components/schemas/Proposition"
    "EvaluateOperation":
      example: {
        "from": "messages",
        "get": "product",
        "similarity": {
          "description": {
            "$get": "message"
          },
          "title": {
            "$get": "message"
          }
        }
      }
      examples:
        - {
          "from": "messages",
          "get": "product",
          "similarity": {
            "description": {
              "$get": "message"
            },
            "title": {
              "$get": "message"
            }
          }
        }
        - {
          "from": "products",
          "get": "product",
          "orderBy": "$p",
          "where": {
            "name": {
              "$get": "name"
            }
          }
        }
        - {
          "from": "products",
          "predict": "category",
          "where": {
            "name": {
              "$get": "name"
            }
          }
        }
        - {
          "from": "messages",
          "match": "product",
          "where": {
            "message": {
              "$get": "message"
            }
          }
        }
      oneOf:
        - $ref: "#/components/schemas/EvaluateSimilarity"
        - $ref: "#/components/schemas/EvaluateGenericQuery"
        - $ref: "#/components/schemas/EvaluatePredict"
        - $ref: "#/components/schemas/EvaluateMatch"
    "OrderBy":
      example: "product.price"
      examples:
        - "product.price"
        - {
          "$asc": "product.price"
        }
        - {
          "$desc": "product.price"
        }
        - {
          "$multiply": ["$p", "prices"]
        }
        - {
          "$pow": ["product.width", 2]
        }
      oneOf:
        - $ref: "#/components/schemas/DescGenericQuery"
        - $ref: "#/components/schemas/AscGenericQuery"
        - $ref: "#/components/schemas/Value"
    "FrequencyAggregateField":
      example: "$f"
      type: string
      enum: ["$f"]
    "BatchQueryResults":
      type: array
      items:
        $ref: "#/components/schemas/DecoratedHits"
    "KnnPropositionObject":
      type: object
      example: {
        "k": 4,
        "near": {
          "tags": "laptop"
        }
      }
      required:
        - "k"
        - "near"
      properties:
        "k":
          example: 4
          type: integer
          format: int32
        "near":
          example: {
            "tags": "laptop"
          }
          oneOf:
            - $ref: "#/components/schemas/Proposition"
            - $ref: "#/components/schemas/PrimitiveProposition"
    "AnyValue":
      example: 4
      examples:
        - 4
        - 3.4
        - true
        - null
        - "text"
        - [1, 2, 3]
        - {
          "field": 4
        }
      oneOf:
        - $ref: "#/components/schemas/IntArray"
        - $ref: "#/components/schemas/LongArray"
        - $ref: "#/components/schemas/DecimalArray"
        - $ref: "#/components/schemas/StringArray"
        - $ref: "#/components/schemas/BooleanArray"
        - type: object
        - type: object
        - type: object
        - type: object
        - type: object
        - type: integer
          format: int32
        - type: integer
          format: int64
        - type: number
        - type: boolean
        - type: "null"
        - type: string
        - type: object
        - type: array
          items:
            type: object
        - $ref: "#/components/schemas/ResponseHit"
        - $ref: "#/components/schemas/PropositionExplanation"
    "DescGenericQuery":
      example: { "$desc": "price" }
      examples:
        - { "$desc": "price" }
        - { "$desc": "product.price" }
        - { "$desc": { "$multiply": ["product.price", "$p"] } }
      type: object
      properties:
        $desc:
          $ref: "#/components/schemas/Value"
    "OptimizeOperation":
      type: object
      example: {
      }
      properties:
    "StartsWith":
      example: { "$startsWith": "Cucumber" }
      examples:
        - { "$startsWith": "Cucumber" }
        - {
          "from": "products",
          "where": {
            "name": { "$startsWith": "Cucumber" }
          }
        }
      type: object
      properties:
        $startsWith:
          oneOf:
            - $ref: "#/components/schemas/ToString"
            - $ref: "#/components/schemas/GetValueExpression"
            - type: string
    "NumericExplanation":
      type: object
      properties:
        $numeric:
          type: number
    "ModificationResult":
      type: object
      required:
        - "operation"
        - "index"
      properties:
        "operation":
          type: string
        "index":
          type: integer
          format: int32
    "Gte":
      example: { "$gte": -2 }
      examples:
        - { "$gte": -2 }
        - { "$gte": 0 }
        - { "$gte": "20180502" }
        - {
          "from": "products",
          "where": {
            "price": { "$gte": 2 }
          }
        }
      type: object
      properties:
        $gte:
          oneOf:
            - $ref: "#/components/schemas/GetValueExpression"
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: "null"
            - $ref: "#/components/schemas/ArrayValue"
            - $ref: "#/components/schemas/ToString"
            - type: boolean
            - type: string
            - $ref: "#/components/schemas/Json"
    "PlainProbability":
      example: "$p"
      examples:
        - "$p"
        - {
          "from": "messages",
          "get": "user",
          "orderBy": "$p",
          "where": {
            "message": {
              "$match": "dog"
            }
          }
        }
      type: string
      enum: ["$p"]
    "Lt":
      example: { "$lt": 4 }
      examples:
        - { "$lt": 4 }
        - { "$lt": -12.1 }
        - { "$lt": "20180502" }
        - {
          "from": "products",
          "where": {
            "price": { "$lt": 1.24 }
          }
        }
      type: object
      properties:
        $lt:
          oneOf:
            - $ref: "#/components/schemas/GetValueExpression"
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: "null"
            - $ref: "#/components/schemas/ArrayValue"
            - $ref: "#/components/schemas/ToString"
            - type: boolean
            - type: string
            - $ref: "#/components/schemas/Json"
    "Gt":
      example: { "$gt": 8 }
      examples:
        - { "$gt": 8 }
        - { "$gt": 231.1 }
        - { "$gt": "20150308" }
        - {
          "from": "products",
          "where": {
            "price": { "$gt": 2.14 }
          }
        }
      type: object
      properties:
        $gt:
          oneOf:
            - $ref: "#/components/schemas/GetValueExpression"
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: "null"
            - $ref: "#/components/schemas/ArrayValue"
            - $ref: "#/components/schemas/ToString"
            - type: boolean
            - type: string
            - $ref: "#/components/schemas/Json"
    "Proposition":
      example: {
        "customer": 4,
        "query": {
          "$match": "laptop"
        }
      }
      examples:
        - {
          "customer": 4,
          "query": {
            "$match": "laptop"
          }
        }
        - {
          "price": {
            "$gte": 50,
            "$lt": 100
          }
        }
        - {
          "tags": {
            "$match": "laptop"
          }
        }
      type: object
      oneOf:
        - $ref: "#/components/schemas/Is"
        - $ref: "#/components/schemas/And"
        - $ref: "#/components/schemas/Atomic"
        - $ref: "#/components/schemas/Or"
        - $ref: "#/components/schemas/Not"
        - $ref: "#/components/schemas/Defined"
        - $ref: "#/components/schemas/Has"
        - $ref: "#/components/schemas/Exists"
        - $ref: "#/components/schemas/Match"
        - $ref: "#/components/schemas/StartsWith"
        - $ref: "#/components/schemas/On"
        - $ref: "#/components/schemas/Hash"
        - $ref: "#/components/schemas/Mod"
        - $ref: "#/components/schemas/Gt"
        - $ref: "#/components/schemas/Gte"
        - $ref: "#/components/schemas/Lt"
        - $ref: "#/components/schemas/Lte"
        - $ref: "#/components/schemas/Context"
        - $ref: "#/components/schemas/Knn"
        - $ref: "#/components/schemas/Nn"
        - $ref: "#/components/schemas/Numeric"
        - oneOf:
            - $ref: "#/components/schemas/ToString"
            - $ref: "#/components/schemas/GetValueExpression"
        - $ref: "#/components/schemas/FieldProposition"
    "EvaluateRecommend":
      type: object
      example: {
        "from": "impressions",
        "goal": {
          "purchase": "true"
        },
        "recommend": "product",
        "where": {
          "product.name": {
            "$get": "query"
          },
          "session.user": {
            "$get": "session.user"
          }
        }
      }
      required:
        - "from"
        - "recommend"
        - "goal"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "product.name": {
              "$get": "query"
            },
            "session.user": {
              "$get": "session.user"
            }
          }
          $ref: "#/components/schemas/Proposition"
        "recommend":
          example: "product"
          $ref: "#/components/schemas/Get"
        "goal":
          example: {
            "purchase": "true"
          }
          $ref: "#/components/schemas/Proposition"
        "select":
          $ref: "#/components/schemas/Projection"
        "offset":
          type: integer
          format: int64
        "limit":
          type: integer
          format: int64
    "NoneExplanation":
      example: {
        "type": "none"
      }
      type: object
      required:
        - type
      properties:
        type:
          description: |
            The explanation type: none
          enum: ["none"]
          type: string
    "Query":
      type: object
      example: {
        "from": "impressions",
        "get": "product",
        "limit": 20,
        "offset": 10
      }
      required:
        - "from"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          $ref: "#/components/schemas/Proposition"
        "get":
          example: "product"
          $ref: "#/components/schemas/Get"
        "orderBy":
          $ref: "#/components/schemas/OrderBy"
        "select":
          $ref: "#/components/schemas/Projection"
        "offset":
          example: 10
          type: integer
          format: int64
          description: The number of results to skip from the beginning.
          default: 0
        "limit":
          example: 20
          type: integer
          format: int64
          description: The maximum number of results to retrieve.
          default: 10
    "MeanScore":
      example: {
        "$mean": {
          "$context": "score"
        }
      }

      type: object
      properties:
        $mean:
          $ref: "#/components/schemas/ContextValueQuery"
    "PrimitiveProposition":
      example: 4
      examples:
        - 4
        - 3.1
        - false
        - null
        - "text"
      oneOf:
        - $ref: "#/components/schemas/GetValueExpression"
        - type: integer
          format: int32
        - type: integer
          format: int64
        - type: number
        - type: "null"
        - $ref: "#/components/schemas/ArrayValue"
        - $ref: "#/components/schemas/ToString"
        - type: boolean
        - type: string
        - $ref: "#/components/schemas/Json"
    "MatchesProjection":
      example: "$matches"
      type: string
      enum: ["$matches"]
    "EvaluateMatch":
      type: object
      example: {
        "from": "impressions",
        "limit": 2,
        "match": "prevProduct",
        "offset": 2,
        "select": ["title", "description", "price"],
        "where": {
          "customer": 4,
          "query": "laptop"
        }
      }
      required:
        - "from"
        - "match"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "customer": 4,
            "query": "laptop"
          }
          $ref: "#/components/schemas/Proposition"
        "select":
          example: ["title", "description", "price"]
          $ref: "#/components/schemas/Projection"
        "match":
          example: "prevProduct"
          $ref: "#/components/schemas/Get"
        "basedOn":
          $ref: "#/components/schemas/PropositionSet"
        "offset":
          example: 2
          type: integer
          format: int64
          description: The number of results to skip from the beginning.
          default: 0
        "limit":
          example: 2
          type: integer
          format: int64
          description: The maximum number of results to retrieve.
          default: 10
    "DecimalArray":
      example: [1.5, 2.7, 3.14]
      type: array
      items:
        type: number
    "Value":
      example: "product.id"
      oneOf:
        - type: string
        - $ref: "#/components/schemas/Score"
    "DefaultValueExplanation":
      example: {
        "type": "default",
        "value": 1.0
      }
      type: object
      required:
        - type
        - value
      properties:
        type:
          description: |
            The explanation type: default value.
          enum: ["default"]
          type: string
        value:
          description: |
            The default value.
          type: number
    "ColumnName":
      example: "id"
      examples:
        - "id"
        - "age"
        - "product.id"
      type: string
    "BaseLiftExplanation":
      example: {
        "type": "baseLift",
        "value": 31.0
      }
      type: object
      required:
        - type
        - value
      properties:
        type:
          description: |
            The explanation type: baseLift.
          enum: ["baseLift"]
          type: string
        value:
          description: |
            The prior lift.
          type: number
    "Multiply":
      example: { "$multiply": ["price", 2] }
      type: object
      properties:
        $multiply:
          type: array
          items:
            $ref: "#/components/schemas/Score"
    "FieldProposition":
      type: object
      required:
        - fieldName
      properties:
        fieldName:
          oneOf:
            - $ref: "#/components/schemas/Proposition"
            - $ref: "#/components/schemas/PrimitiveProposition"
    "PropositionField":
      example: "$proposition"
      type: string
      enum: ["$proposition"]
    "Decision":
      example: {
        "$decision": {
          "score": {"$mean": {"$context": "clickThroughRate"}},
          "seed": 0
        }
      }

      type: object
      properties:
        $decision:
          type: object
          properties:
            "score":
              $ref: "#/components/schemas/Score"
            "seed":
              type: integer
              format: int64
    "PlainSameness":
      example: "$sameness"
      examples:
        - "$sameness"
        - {
          "from": "product",
          "orderBy": "$sameness",
          "where": {
            "title": {
              "$match": "iphone"
            }
          }
        }
      type: string
      enum: ["$sameness"]
    "ProjectionField":
      example: "price"
      type: string
    "FromTablequery":
      example: "impressions"
      examples:
        - "impressions"
        - "products"
        - "customers"
        - "messages"
      type: string
    "DecoratedHits":
      type: object
      example: {
        "hits": [{
          "category": "108",
          "id": "6411300000494",
          "name": "Juhla Mokka coffee 500g sj",
          "price": 3.95,
          "tags": "coffee"
        }],
        "offset": 0,
        "total": 1
      }
      required:
        - "offset"
        - "total"
        - "hits"
      properties:
        "offset":
          example: 0
          type: integer
          format: int64
        "total":
          example: 1
          type: integer
          format: int64
        "hits":
          example: [{
            "category": "108",
            "id": "6411300000494",
            "name": "Juhla Mokka coffee 500g sj",
            "price": 3.95,
            "tags": "coffee"
          }]
          $ref: "#/components/schemas/Hits"
    "ExponentialExplanation":
      example: {
        "inner": {
          "components": [],
          "type": "weighted_average",
          "value": -1.754
        },
        "type": "exp",
        "value": 0.173
      }
      type: object
      required:
        - type
        - value
        - inner
      properties:
        type:
          description: |
            The explanation type: exp (exponential transformation).
          enum: ["exp"]
          type: string
        value:
          description: |
            The exponential score value exp(inner).
          type: number
        inner:
          description: |
            The explanation in log space that gets exponentiated.
          $ref: "#/components/schemas/ScoreExplanation"
    "Context":
      example: { "$context": { "click": true } }
      examples:
        - { "$context": { "click": true } }
        - {
          "from": "impressions",
          "where": {
            "customerEmail": "john.doe@aito.ai",
            "query": "laptop"
          },
          "get": "product",
          "orderBy": { "$p": { "$context": { "click": true } } }
        }
      type: object
      properties:
        $context:
          $ref: "#/components/schemas/Proposition"
    "AnyQuery":
      oneOf:
        - $ref: "#/components/schemas/SimilarityQuery"
        - $ref: "#/components/schemas/PredictQuery"
        - $ref: "#/components/schemas/RecommendQuery"
        - $ref: "#/components/schemas/MatchQuery"
        - $ref: "#/components/schemas/RelateQuery"
        - $ref: "#/components/schemas/Query"
        - $ref: "#/components/schemas/SearchQuery"
    "StringArray":
      example: ["red", "green", "blue"]
      type: array
      items:
        type: string
    "Sum":
      example: { "$sum": ["priceNet", "priceVat"] }
      type: object
      properties:
        $sum:
          oneOf:
            - $ref: "#/components/schemas/ContextValueQuery"
            - type: array
              items:
                $ref: "#/components/schemas/Score"
    "OnExplanation":
      type: object
      properties:
        $on:
          type: array
          items:
            $ref: "#/components/schemas/PropositionExplanation"
    "GtExplanation":
      type: object
      properties:
        $gt:
          oneOf:
            - $ref: "#/components/schemas/IntArray"
            - $ref: "#/components/schemas/LongArray"
            - $ref: "#/components/schemas/DecimalArray"
            - $ref: "#/components/schemas/StringArray"
            - $ref: "#/components/schemas/BooleanArray"
            - type: object
            - type: object
            - type: object
            - type: object
            - type: object
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: boolean
            - type: "null"
            - type: string
            - type: object
    "ProjectionList":
      example: ["$f", "price", "tags", {
        "$mean": {
          "$context": "score"
        }
      }]
      type: array
      items:
        $ref: "#/components/schemas/Projection"
    "EstimateResult":
      example: {
        "name": "My product",
        "price": 172.19
      }
      examples:
        - {
          "name": "My product",
          "price": 172.19
        }
        - {
          "$score": 0.22350516297675496,
          "$value": "coffee",
          "$why": {
            "factors": [{
              "factors": [{
                "proposition": {
                  "name": {
                    "$has": "coffee"
                  }
                },
                "type": "relatedPropositionLift",
                "value": 8.45603245079726
              }],
              "proposition": "coffee",
              "type": "hitPropositionLift",
              "value": 8.45603245079726
            }],
            "type": "product"
          }
        }
      oneOf:
        - $ref: "#/components/schemas/UserDefinedObject"
        - $ref: "#/components/schemas/PropositionExplanation"
        - type: object
        - $ref: "#/components/schemas/ScoreExplanation"
    "ScoreOperator":
      example: "$p"
      examples:
        - "$p"
        - "$similarity"
        - {
          "$multiply": ["$p", "margin"]
        }
      oneOf:
        - $ref: "#/components/schemas/PlainProbability"
        - $ref: "#/components/schemas/Frequency"
        - $ref: "#/components/schemas/PlainLift"
        - $ref: "#/components/schemas/PlainSimilarity"
        - $ref: "#/components/schemas/PlainSameness"
        - $ref: "#/components/schemas/Hit"
        - $ref: "#/components/schemas/ProbabilityScore"
        - $ref: "#/components/schemas/ParametricProbabilityScore"
        - $ref: "#/components/schemas/LiftScore"
        - $ref: "#/components/schemas/ParametricLiftScore"
        - $ref: "#/components/schemas/ContextFrequencyScore"
        - $ref: "#/components/schemas/MeanScore"
        - $ref: "#/components/schemas/MinScore"
        - $ref: "#/components/schemas/MaxScore"
        - $ref: "#/components/schemas/ImpactScore"
        - $ref: "#/components/schemas/FreqP"
        - $ref: "#/components/schemas/Decision"
        - $ref: "#/components/schemas/SimilarityScore"
        - $ref: "#/components/schemas/SamenessScore"
        - $ref: "#/components/schemas/AnalogyScore"
        - $ref: "#/components/schemas/Multiply"
        - $ref: "#/components/schemas/Divide"
        - $ref: "#/components/schemas/Sum"
        - $ref: "#/components/schemas/Subtract"
        - $ref: "#/components/schemas/Pow"
        - $ref: "#/components/schemas/Normalize"
    "ContextFrequencyScore":
      example: {
        "$f": {
          "$context": { "click": false }
        }
      }

      examples:
        - {
          "$f": {
            "$context": { "click": false }
          }
        }

        - {
          "from": "impressions",
          "get": "product",
          "orderBy": {
            "$f": { "$context": { "$click": true } }
          }
        }
      type: object
      properties:
        $f:
          $ref: "#/components/schemas/ContextPropositionQuery"
    "ParametricLiftScore":
      example: { "$probabilityLift": {"of": "tags" } }
      examples:
        - { "$probabilityLift": {"of": "tags" } }
        - { "$probabilityLift": {"of": ["tags", "title"] } }
        - {
          "$probabilityLift": {
            "of": { "$context": { "click": true } },
            "basedOn": ["title", "tags", "category"]
          }
        }

        - {
          "from": "impressions",
          "where": {
            "product.title": {
              "$match": "iphone"
            }
          },
          "get": "product",
          "orderBy": {
            "$probabilityLift": { "of": "tags" }
          }
        }

      type: object
      properties:
        $probabilityLift:
          type: object
          properties:
            "of":
              $ref: "#/components/schemas/PropositionSet"
            "basedOn":
              $ref: "#/components/schemas/PropositionSet"
    "Expand":
      example: { "$expand": {"$mean": {"$context": "score"} } }
      type: object
      properties:
        $expand:
          $ref: "#/components/schemas/ScoreOperator"
    "Is":
      example: { "$is": "value" }
      type: object
      properties:
        $is:
          $ref: "#/components/schemas/PrimitiveProposition"
    "ExponentPropositionArray":
      example: ["width", 2]
      type: array
      minItems: 2
      maxItems: 2
      items:
        $ref: "#/components/schemas/Score"
    "SamenessScore":
      example: { "$sameness": { "title": "apple iphone", "tags": "premium ios phone" } }
      examples:
        - { "$sameness": { "title": "apple iphone", "tags": "premium ios phone" } }
        - {
          "from": "products",
          "orderBy": {
            "$sameness": {
              "title": "apple iphone",
              "tags": "premium ios phone"
            }
          }
        }

      type: object
      properties:
        $sameness:
          oneOf:
            - $ref: "#/components/schemas/Proposition"
            - $ref: "#/components/schemas/PrimitiveProposition"
    "ModPropositionArray":
      example: [2, 0]
      type: array
      minItems: 2
      maxItems: 2
      items:
        type: integer
        format: int64
    "EstimateQuery":
      type: object
      example: {
        "estimate": "price",
        "from": "products",
        "where": {
          "brand": "Premium",
          "category": "Electronics"
        }
      }
      required:
        - "from"
        - "estimate"
      properties:
        "from":
          example: "products"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "brand": "Premium",
            "category": "Electronics"
          }
          $ref: "#/components/schemas/Proposition"
        "estimate":
          example: "price"
          type: string
        "model":
          type: string
        "select":
          $ref: "#/components/schemas/Selection"
    "ParametricProbabilityScore":
      example: { "$probability": {"of": "tags" } }
      examples:
        - { "$probability": {"of": "tags" } }
        - { "$probability": {"of": ["tags", "title"] } }
        - {
          "$probability": {
            "of": { "$context": { "click": true } },
            "basedOn": ["title", "tags", "category"]
          }
        }

        - {
          "from": "impressions",
          "where": {
            "product.title": {
              "$match": "iphone"
            }
          },
          "get": "product",
          "orderBy": {
            "$probability": {"of": "tags"}
          }
        }

      type: object
      properties:
        $probability:
          type: object
          properties:
            "of":
              $ref: "#/components/schemas/PropositionSet"
            "basedOn":
              $ref: "#/components/schemas/PropositionSet"
    "SortField":
      example: "$sort"
      type: string
      enum: ["$sort"]
    "Mod":
      example: { "$mod": [2, 0] }
      examples:
        - { "$mod": [2, 0] }
        - { "$mod": { "divisor": 2, "remainder": 0 } }
        - {
          "from": "products",
          "where": {
            "price": { "$mod": { "divisor": 2, "remainder": 0 } }
          }
        }
      type: object
      properties:
        $mod:
          oneOf:
            - $ref: "#/components/schemas/ModPropositionObject"
            - $ref: "#/components/schemas/ModPropositionArray"
    "ContextPropositionQuery":
      example: {
        "$context": { "click": true }
      }

      type: object
      properties:
        $context:
          $ref: "#/components/schemas/Proposition"
    "ValueField":
      example: "$value"
      type: string
      enum: ["$value"]
    "Lte":
      example: { "$lte": 8 }
      examples:
        - { "$lte": 8 }
        - { "$lte": 0 }
        - { "$lte": "20180502" }
        - {
          "from": "products",
          "where": {
            "price": { "$lte": 1 }
          }
        }
      type: object
      properties:
        $lte:
          oneOf:
            - $ref: "#/components/schemas/GetValueExpression"
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: "null"
            - $ref: "#/components/schemas/ArrayValue"
            - $ref: "#/components/schemas/ToString"
            - type: boolean
            - type: string
            - $ref: "#/components/schemas/Json"
    "KnnPropositionArray":
      example: [4, {
        "tags": "laptop"
      }]
      type: array
      minItems: 2
      maxItems: 2
      items:
        oneOf:
          - type: integer
            format: int32
          - oneOf:
              - $ref: "#/components/schemas/Proposition"
              - $ref: "#/components/schemas/PrimitiveProposition"
    "NnExplanation":
      type: object
      properties:
        $nn:
          type: object
          properties:
            "near":
              type: array
              items:
                $ref: "#/components/schemas/PropositionExplanation"
    "FieldPropositionExplanation":
      type: object
      required:
        - fieldName
      properties:
        fieldName:
          $ref: "#/components/schemas/PropositionExplanation"
    "NamedAggregateProjection":
      example: {
        "aggregate": {
          "clicks": {
            "$f": {
              "click": true
            }
          },
          "ctr": {
            "$mean": "click"
          },
          "impressions": "$f"
        },
        "from": "impressions",
        "where": {
          "product.name": "MyProduct"
        }
      }
      examples:
        - {
          "aggregate": {
            "clicks": {
              "$f": {
                "click": true
              }
            },
            "ctr": {
              "$mean": "click"
            },
            "impressions": "$f"
          },
          "from": "impressions",
          "where": {
            "product.name": "MyProduct"
          }
        }
        - {
          "failureCount": {
            "$f": {
              "success": false
            }
          }
        }
      type: object
    "AggregateSum":
      example: { "$sum": "visits" }
      examples:
        - { "$sum": "visits" }
        - { "$sum": "purchase" }
      type: object
      properties:
        $sum:
          $ref: "#/components/schemas/Score"
    "InverseDocumentFrequencyExplanation":
      example: {
        "type": "idf",
        "value": 1.7551720221592049
      }
      type: object
      required:
        - type
        - value
      properties:
        type:
          description: |
            The explanation type: idf.
          enum: ["idf"]
          type: string
        value:
          description: |
            The inverse document frequency score.
          type: number
    "CopyTableOperation":
      type: object
      example: {
        "copy": "new_table",
        "from": "old_table"
      }
      required:
        - "from"
        - "copy"
      properties:
        "from":
          example: "old_table"
          $ref: "#/components/schemas/FromTablemodify"
          description: The existing table to copy
        "copy":
          example: "new_table"
          $ref: "#/components/schemas/FromTablemodify"
          description: The target name of the new copy
        "replace":
          type: boolean
          description: If replace is true, operation will overwrite any existing table
          default: false
    "Score":
      example: 2.0
      examples:
        - 2.0
        - "product.margin"
        - "$p"
        - "$similarity"
        - {
          "$multiply": ["$p", "margin"]
        }
      oneOf:
        - $ref: "#/components/schemas/ScoreOperator"
        - $ref: "#/components/schemas/ColumnName"
        - type: number
    "DefinedExplanation":
      type: object
      properties:
        $defined:
          type: boolean
    "ConstantExplanation":
      type: object
      required:
        - type
        - value
      properties:
        type:
          description: |
            The explanation type
          enum: ["constant"]
          type: string
        value:
          type: number
    "HitLinkPropositionLiftExplanation":
      example: {
        "proposition": {
          "product": 5
        },
        "type": "hitLinkPropositionLift",
        "value": 2.32
      }
      type: object
      required:
        - type
        - proposition
        - value
      properties:
        type:
          description: |
            The explanation type: hitLinkPropositionLift
          enum: ["hitLinkPropositionLift"]
          type: string
        proposition:
          description: |
            The link proposition.
          $ref: "#/components/schemas/PropositionExplanation"
        value:
          description: |
            The lift value of the linked proposition.
          type: number
    "Exists":
      example: { "$exists": ["query", "product.tags"] }
      examples:
        - { "$exists": ["query", "product.tags"] }
        - {
          "from": "impressions",
          "where": {
            "$on": [
              { "$exists": ["query", "customer.tags"] },
              { "click": true }
            ]
          },
          "relate": ["product.title", "product.tags"]
        }
      type: object
      properties:
        $exists:
          $ref: "#/components/schemas/PropositionSet"
    "SimilarityScore":
      example: { "$similarity": { "title": "apple iphone", "tags": "premium ios phone" } }
      examples:
        - { "$similarity": { "title": "apple iphone", "tags": "premium ios phone" } }
        - {
          "from": "products",
          "orderBy": {
            "$similarity": {
              "title": "apple iphone",
              "tags": "premium ios phone"
            }
          }
        }

      type: object
      properties:
        $similarity:
          oneOf:
            - $ref: "#/components/schemas/Proposition"
            - $ref: "#/components/schemas/PrimitiveProposition"
    "IndexField":
      example: "$index"
      type: string
      enum: ["$index"]
    "PredictQuery":
      type: object
      example: {
        "from": "impressions",
        "limit": 2,
        "offset": 2,
        "predict": "prevProduct",
        "where": {
          "customer": 4,
          "query": "laptop"
        }
      }
      required:
        - "from"
        - "predict"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "customer": 4,
            "query": "laptop"
          }
          $ref: "#/components/schemas/Proposition"
        "predict":
          example: "prevProduct"
          $ref: "#/components/schemas/PropositionSet"
        "basedOn":
          $ref: "#/components/schemas/PropositionSet"
          description: if predicted variable links to another table, basedOn is used to specify the fields in that table used to calculate prior estimate
        "exclusiveness":
          type: boolean
          description: |
            Exclusiveness dictates that only one feature can be true at the same time and that one feature will be true.

            In practice, exclusiveness enforces the probabilities of alternative features to
            sum to 1.0. This is achieved with a normalizer. The normalizer is of form:

            ```
            1 / sum((p(X_0) + p(X_1) + ...))
            ```
          default: true
        "select":
          $ref: "#/components/schemas/Projection"
        "offset":
          example: 2
          type: integer
          format: int64
          description: The number of results to skip from the beginning.
          default: 0
        "limit":
          example: 2
          type: integer
          format: int64
          description: The maximum number of results to retrieve.
          default: 10
    "Normalize":
      example: { "$normalize": "$lift" }
      examples:
        - { "$normalize": "$lift" }
        - { "$normalize": { "$lift": "name" } }
      type: object
      properties:
        $normalize:
          $ref: "#/components/schemas/Score"
    "ParametricWhy":
      example: {
        "$why": {
          "highlight": {
            "posPreTag": "<b>",
            "posPostTag": "</b>",
            "negPreTag": "<em>",
            "negPostTag": "</em>",
            "encoder": "html",
            "posThreshold": 1.1,
            "negThreshold": 0.9
          },
          "matches": {}
        }
      }
      type: object
      properties:
        $why:
          type: object
          properties:
            "highlight":
              $ref: "#/components/schemas/HighlightParams"
            "matches":
              type: object
              properties:
    "Atomic":
      example: { "$atomic": { "tags": "pen", "price": { "$gte": 200 } } }
      examples:
        - { "$atomic": { "tags": "pen", "price": { "$gte": 200 } } }
        - {
          "from": "products",
          "where": {
            "$atomic": {
              "tags": "pen",
              "price": { "$gte": 200 }
            }
          }
        }
      type: object
      properties:
        $atomic:
          $ref: "#/components/schemas/Proposition"
    "HighlightProjection":
      example: "$highlight"
      type: string
      enum: ["$highlight"]
    "HighlightParams":
      type: object
      example: {
        "encoder": "html",
        "negPostTag": "</em>",
        "negPreTag": "<em>",
        "negThreshold": 0.9,
        "posPostTag": "</b>",
        "posPreTag": "<b>",
        "posThreshold": 1.1
      }
      properties:
        "posPreTag":
          example: "<b>"
          type: string
        "posPostTag":
          example: "</b>"
          type: string
        "negPreTag":
          example: "<em>"
          type: string
        "negPostTag":
          example: "</em>"
          type: string
        "posThreshold":
          example: 1.1
          type: number
        "negThreshold":
          example: 0.9
          type: number
        "encoder":
          example: "html"
          type: string
    "PropositionExplanation":
      oneOf:
        - $ref: "#/components/schemas/FieldPropositionExplanation"
        - $ref: "#/components/schemas/HasExplanation"
        - $ref: "#/components/schemas/AndExplanation"
        - $ref: "#/components/schemas/OrExplanation"
        - $ref: "#/components/schemas/OnExplanation"
        - $ref: "#/components/schemas/NotExplanation"
        - $ref: "#/components/schemas/StartsWithExplanation"
        - $ref: "#/components/schemas/GtExplanation"
        - $ref: "#/components/schemas/GteExplanation"
        - $ref: "#/components/schemas/LtExplanation"
        - $ref: "#/components/schemas/LteExplanation"
        - $ref: "#/components/schemas/DefinedExplanation"
        - $ref: "#/components/schemas/NumericExplanation"
        - $ref: "#/components/schemas/KnnExplanation"
        - $ref: "#/components/schemas/NnExplanation"
        - $ref: "#/components/schemas/IsPropositionExplanation"
    "Not":
      example: { "$not": { "tags": "laptop" } }
      examples:
        - { "$not": { "tags": "laptop" } }
        - { "$not": { "$lt": 0 } }
        - {
          "from": "products",
          "where": {
            "price": {
              "$not": { "$lt": 1.1 }
            }
          }
        }
      type: object
      properties:
        $not:
          oneOf:
            - $ref: "#/components/schemas/Proposition"
            - $ref: "#/components/schemas/PrimitiveProposition"
    "Knn":
      example: { "$knn": [4, {"tags": "laptop" }] }
      examples:
        - { "$knn": [4, {"tags": "laptop" }] }
        - { "$knn": { "k": 4, "near": {"tags": "laptop" } } }
      type: object
      properties:
        $knn:
          oneOf:
            - $ref: "#/components/schemas/KnnPropositionObject"
            - $ref: "#/components/schemas/KnnPropositionArray"
    "HitPropositionLiftExplanation":
      example: {
        "factors": [{
          "type": "baseLift",
          "value": 31.0
        }],
        "proposition": {
          "field": 4
        },
        "type": "hitPropositionLift",
        "value": 31.0
      }
      type: object
      required:
        - type
        - proposition
        - value
        - factors
      properties:
        type:
          description: |
            The explanation type: hitPropositionLift.
          enum: ["hitPropositionLift"]
          type: string
        proposition:
          description: |
            The proposition.
          $ref: "#/components/schemas/PropositionExplanation"
        value:
          description: |
            The aggregated lift value.
          type: number
        factors:
          description: |
            The factors contributing to the aggregated lift and their explanation.
          type: array
          items:
            $ref: "#/components/schemas/ScoreExplanation"
    "ArrayValue":
      oneOf:
        - type: object
        - type: object
        - type: object
        - type: object
        - type: object
        - type: object
        - type: object
        - type: object
        - type: object
        - type: object
    "NamedProjection":
      example: {
        "from": "impressions",
        "get": "product",
        "select": {
          "clicks": {
            "$f": {
              "$context": {
                "click": true
              }
            }
          },
          "ctr": {
            "$mean": {
              "$context": "click"
            }
          },
          "impressions": "$f",
          "product": "name"
        }
      }
      examples:
        - {
          "from": "impressions",
          "get": "product",
          "select": {
            "clicks": {
              "$f": {
                "$context": {
                  "click": true
                }
              }
            },
            "ctr": {
              "$mean": {
                "$context": "click"
              }
            },
            "impressions": "$f",
            "product": "name"
          }
        }
        - {
          "failures": {
            "$f": {
              "$context": {
                "success": false
              }
            }
          }
        }
        - {
          "id": "id",
          "mean": {
            "$mean": {
              "$context": "product.price"
            }
          }
        }
        - {
          "$value": "$value",
          "field": "field",
          "id": "id"
        }
      type: object
    "Subtract":
      example: { "$subtract": ["price", 2] }
      type: object
      properties:
        $subtract:
          oneOf:
            - type: object
              properties:
                "minuend":
                  $ref: "#/components/schemas/Score"
                "subtrahend":
                  $ref: "#/components/schemas/Score"
            - type: array
              minItems: 2
              maxItems: 2
              items:
                $ref: "#/components/schemas/Score"
    "EvaluateSimilarity":
      type: object
      example: {
        "from": "messages",
        "get": "product",
        "similarity": {
          "description": {
            "$get": "message"
          },
          "title": {
            "$get": "message"
          }
        }
      }
      required:
        - "from"
        - "get"
        - "similarity"
      properties:
        "from":
          example: "messages"
          $ref: "#/components/schemas/From"
        "where":
          $ref: "#/components/schemas/Proposition"
        "get":
          example: "product"
          $ref: "#/components/schemas/Get"
        "similarity":
          example: {
            "description": {
              "$get": "message"
            },
            "title": {
              "$get": "message"
            }
          }
          oneOf:
            - $ref: "#/components/schemas/Proposition"
            - $ref: "#/components/schemas/PrimitiveProposition"
        "select":
          $ref: "#/components/schemas/Projection"
        "offset":
          type: integer
          format: int64
        "limit":
          type: integer
          format: int64
    "FreqP":
      example: {
        "$freqP": {
          "f": "clickCount",
          "n": "impressionCount",
          "p": 0.5
        }
      }

      type: object
      properties:
        $freqP:
          type: object
          properties:
            "f":
              $ref: "#/components/schemas/Value"
            "n":
              $ref: "#/components/schemas/Value"
            "p":
              $ref: "#/components/schemas/Value"
    "EvaluateQueryBase":
      oneOf:
        - $ref: "#/components/schemas/EvaluateGroupedQuery"
        - $ref: "#/components/schemas/EvaluateEstimateQuery"
        - $ref: "#/components/schemas/EvaluateQuery"
    "MatchesField":
      example: "$matches"
      type: string
      enum: ["$matches"]
    "SumExplanation":
      example: {
        "terms": [{
          "field": "id",
          "type": "field",
          "value": 4.0
        }, {
          "field": "price",
          "type": "field",
          "value": 1500.0
        }],
        "type": "sum"
      }
      type: object
      required:
        - type
        - terms
      properties:
        type:
          description: |
            The explanation type: sum.
          enum: ["sum"]
          type: string
        terms:
          description: |
            The explanation of the summed score's terms.
          type: array
          items:
            $ref: "#/components/schemas/ScoreExplanation"
    "EvaluateEstimate":
      type: object
      example: {
        "estimate": "price",
        "from": "products",
        "where": {
          "category": {
            "$get": "category"
          }
        }
      }
      required:
        - "from"
        - "estimate"
      properties:
        "from":
          example: "products"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "category": {
              "$get": "category"
            }
          }
          $ref: "#/components/schemas/Proposition"
        "estimate":
          example: "price"
          type: string
        "basedOn":
          $ref: "#/components/schemas/PropositionSet"
    "WhyField":
      example: "$why"
      type: string
      enum: ["$why"]
    "DivisionExplanation":
      example: {
        "dividend": {
          "field": "return",
          "type": "field",
          "value": 400000.0
        },
        "divisor": {
          "field": "investment",
          "type": "field",
          "value": 250000.0
        },
        "type": "division"
      }
      type: object
      required:
        - type
        - dividend
        - divisor
      properties:
        type:
          description: |
            The explanation type: divide.
          enum: ["division"]
          type: string
        dividend:
          description: |
            The divided value.
          $ref: "#/components/schemas/ScoreExplanation"
        divisor:
          description: |
            The divider value.
          $ref: "#/components/schemas/ScoreExplanation"
    "StartsWithExplanation":
      type: object
      properties:
        $startsWith:
          type: string
    "PlainLift":
      example: "$lift"
      examples:
        - "$lift"
        - {
          "from": "messages",
          "get": "user",
          "orderBy": "$lift",
          "where": {
            "message": {
              "$match": "dog"
            }
          }
        }
      type: string
      enum: ["$lift"]
    "Pow":
      example: { "$pow": ["width", 2] }
      type: object
      properties:
        $pow:
          oneOf:
            - $ref: "#/components/schemas/ExponentPropositionObject"
            - $ref: "#/components/schemas/ExponentPropositionArray"
    "MatchQuery":
      type: object
      example: {
        "from": "impressions",
        "limit": 2,
        "match": "prevProduct",
        "offset": 2,
        "select": ["title", "description", "price"],
        "where": {
          "customer": 4,
          "query": "laptop"
        }
      }
      required:
        - "from"
        - "match"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "customer": 4,
            "query": "laptop"
          }
          $ref: "#/components/schemas/Proposition"
        "select":
          example: ["title", "description", "price"]
          $ref: "#/components/schemas/Projection"
        "match":
          example: "prevProduct"
          $ref: "#/components/schemas/Get"
        "basedOn":
          $ref: "#/components/schemas/PropositionSet"
        "offset":
          example: 2
          type: integer
          format: int64
          description: The number of results to skip from the beginning.
          default: 0
        "limit":
          example: 2
          type: integer
          format: int64
          description: The maximum number of results to retrieve.
          default: 10
    "Hits":
      example: [{
        "$p": 0.16772371915637704,
        "category": "100",
        "id": "6410405060457",
        "name": "Pirkka bio cherry tomatoes 250g international 1st class",
        "price": 1.29,
        "tags": "fresh vegetable pirkka tomato"
      }, {
        "$p": 0.16772371915637704,
        "category": "100",
        "id": "6410405093677",
        "name": "Pirkka iceberg salad Finland 100g 1st class",
        "price": 1.29,
        "tags": "fresh vegetable pirkka"
      }]
      type: array
      items:
        $ref: "#/components/schemas/ResponseHit"
    "RelatedPropositionLiftExplanation":
      type: object
      required:
        - type
        - proposition
        - value
      properties:
        type:
          description: |
            The explanation type: relatedPropositionLift.
          enum: ["relatedPropositionLift"]
          type: string
        proposition:
          description: |
            The related proposition.
          $ref: "#/components/schemas/PropositionExplanation"
        value:
          description: |
            The lift value of the related proposition.
          type: number
    "EvaluateGenericQuery":
      type: object
      example: {
        "from": "impressions",
        "get": "product",
        "limit": 20,
        "offset": 10
      }
      required:
        - "from"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          $ref: "#/components/schemas/Proposition"
        "get":
          example: "product"
          $ref: "#/components/schemas/Get"
        "orderBy":
          $ref: "#/components/schemas/OrderBy"
        "select":
          $ref: "#/components/schemas/Projection"
        "offset":
          example: 10
          type: integer
          format: int64
          description: The number of results to skip from the beginning.
          default: 0
        "limit":
          example: 20
          type: integer
          format: int64
          description: The maximum number of results to retrieve.
          default: 10
    "AggregateQuery":
      type: object
      example: {
        "aggregate": ["click.$sum", "click.$mean"],
        "from": "impressions",
        "where": {
          "customer": 4
        }
      }
      required:
        - "from"
        - "aggregate"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "customer": 4
          }
          $ref: "#/components/schemas/Proposition"
        "aggregate":
          example: ["click.$sum", "click.$mean"]
          $ref: "#/components/schemas/AggregateProjection"
        "select":
          $ref: "#/components/schemas/Selection"
    "OnPropositionArray":
      example: [{
        "click": true
      }, {
        "user.tags": "nyc"
      }]
      type: array
      minItems: 2
      maxItems: 2
      items:
        $ref: "#/components/schemas/Proposition"
    "SimilarityQuery":
      type: object
      example: {
        "from": "impressions",
        "limit": 2,
        "offset": 2,
        "similarity": {
          "query": "laptop"
        },
        "where": {
          "click": "true"
        }
      }
      required:
        - "from"
        - "similarity"
      properties:
        "from":
          example: "impressions"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "click": "true"
          }
          $ref: "#/components/schemas/Proposition"
        "similarity":
          example: {
            "query": "laptop"
          }
          $ref: "#/components/schemas/Proposition"
        "select":
          $ref: "#/components/schemas/Projection"
        "offset":
          example: 2
          type: integer
          format: int64
          description: The number of results to skip from the beginning.
          default: 0
        "limit":
          example: 2
          type: integer
          format: int64
          description: The maximum number of results to retrieve.
          default: 10
    "Match":
      example: { "$match": "coffee" }
      examples:
        - { "$match": "coffee" }
        - {
          "from": "products",
          "where": {
            "name": { "$match": "coffee" }
          }
        }
      type: object
      properties:
        $match:
          oneOf:
            - $ref: "#/components/schemas/ToString"
            - $ref: "#/components/schemas/GetValueExpression"
            - type: string
    "BatchQuery":
      type: array
      items:
        $ref: "#/components/schemas/AnyQuery"
    "AnyModification":
      oneOf:
        - $ref: "#/components/schemas/InsertOperation"
        - $ref: "#/components/schemas/UpdateOperation"
        - $ref: "#/components/schemas/DeleteOperation2"
        - $ref: "#/components/schemas/OptimizeOperation2"
        - $ref: "#/components/schemas/RenameTableOperation"
        - $ref: "#/components/schemas/CopyTableOperation"
        - $ref: "#/components/schemas/OperationsWrapper"
    "NamedExplanation":
      example: {
        "name": "exclusiveness",
        "type": "normalizer",
        "value": 0.2982788431762749
      }
      type: object
      required:
        - type
        - name
        - value
      properties:
        type:
          description: |
            Normalizer.
          type: string
        name:
          description: |
            Exclusiveness.
          type: string
        value:
          description: |
            The value of the normalizer.
          type: number
    "ContextValueQuery":
      example: {
        "$context": "click"
      }

      type: object
      properties:
        $context:
          $ref: "#/components/schemas/Value"
    "DecoratedScoreExplanation":
      type: object
    "ImpactScore":
      example: {
        "$impact": {
          "value": { "$context": "score" },
          "base": 2.5
        }
      }

      examples:
        - {
          "$impact": {
            "value": { "$context": "score" },
            "base": 2.5
          }
        }

        - {
          "from": "projects",
          "get": "customer.industry",
          "orderBy": {
            "$impact": {
              "value": { "$context": "profit" }
            }
          }
        }
      type: object
      properties:
        $impact:
          type: object
          properties:
            "value":
              $ref: "#/components/schemas/ContextValueQuery"
            "base":
              type: number
    "AggregateList":
      example: ["$f", "price", "tags", {
        "$mean": "score"
      }]
      type: array
      items:
        $ref: "#/components/schemas/AggregateProjection"
    "ParametricMatches":
      example: { "$matches": {} }
      type: object
      properties:
        $matches:
          type: object
          properties:
    "BaseProbabilityExplanation":
      example: {
        "proposition": {
          "click": true
        },
        "type": "baseP",
        "value": 0.5
      }
      type: object
      required:
        - type
        - value
      properties:
        type:
          description: |
            The explanation type: baseP.
          enum: ["baseP"]
          type: string
        value:
          description: |
            The prior probability.
          type: number
        proposition:
          description: |
            The variable.
          $ref: "#/components/schemas/PropositionExplanation"
    "IsPropositionExplanation":
      oneOf:
        - $ref: "#/components/schemas/IntArray"
        - $ref: "#/components/schemas/LongArray"
        - $ref: "#/components/schemas/DecimalArray"
        - $ref: "#/components/schemas/StringArray"
        - $ref: "#/components/schemas/BooleanArray"
        - type: object
        - type: object
        - type: object
        - type: object
        - type: object
        - type: integer
          format: int32
        - type: integer
          format: int64
        - type: number
        - type: boolean
        - type: "null"
        - type: string
        - type: object
    "PredictExplanation":
      example: {
        "factors": [{
          "type": "baseP",
          "value": 0.8048780487804879
        }, {
          "name": "exclusiveness",
          "type": "normalizer",
          "value": 0.04604801347746731
        }],
        "type": "product"
      }
      type: object
      required:
        - type
        - factors
      properties:
        type:
          description: |
            The explanation type: product.
          enum: ["product"]
          type: string
        factors:
          description: |
            The explanation of the probability's factors
          type: array
          items:
            $ref: "#/components/schemas/ScoreExplanation"
    "OnPropositionObject":
      type: object
      example: {
        "on": {
          "user.tags": "nyc"
        },
        "prop": {
          "click": true
        }
      }
      required:
        - "prop"
        - "on"
      properties:
        "prop":
          example: {
            "click": true
          }
          $ref: "#/components/schemas/Proposition"
        "on":
          example: {
            "user.tags": "nyc"
          }
          $ref: "#/components/schemas/Proposition"
    "Selection":
      example: ["user.name", "query", "product.title", "click"]
      examples:
        - ["user.name", "query", "product.title", "click"]
        - ["$why"]
      type: array
      items:
        oneOf:
          - type: string
          - $ref: "#/components/schemas/IndexField"
          - $ref: "#/components/schemas/WhyField"
          - $ref: "#/components/schemas/MatchesField"
          - $ref: "#/components/schemas/ValueField"
          - $ref: "#/components/schemas/PropositionField"
          - $ref: "#/components/schemas/SortField"
          - $ref: "#/components/schemas/ScoreField"
          - $ref: "#/components/schemas/PField"
    "Json":
      type: object
      properties:
        $json:
          type: object
    "EvaluatePredict":
      type: object
      example: {
        "from": "products",
        "predict": "category",
        "where": {
          "name": {
            "$get": "name"
          }
        }
      }
      required:
        - "from"
        - "predict"
      properties:
        "from":
          example: "products"
          $ref: "#/components/schemas/From"
        "where":
          example: {
            "name": {
              "$get": "name"
            }
          }
          $ref: "#/components/schemas/Proposition"
        "predict":
          example: "category"
          $ref: "#/components/schemas/PropositionSet"
        "basedOn":
          $ref: "#/components/schemas/PropositionSet"
        "exclusiveness":
          type: boolean
        "select":
          $ref: "#/components/schemas/Projection"
        "offset":
          type: integer
          format: int64
        "limit":
          type: integer
          format: int64
    "From":
      example: {
        "from": "impressions",
        "where": {
          "click": true
        }
      }
      examples:
        - {
          "from": "impressions",
          "where": {
            "click": true
          }
        }
        - "impressions"
        - {
          "from": {
            "from": "impressions",
            "where": {
              "click": true
            }
          },
          "orderBy": "$p",
          "where": {
            "query": "laptop"
          }
        }
        - {
          "from": "impressions"
        }
      oneOf:
        - $ref: "#/components/schemas/FromWhere"
        - $ref: "#/components/schemas/FromTablequery"
    "AggregateMean":
      example: { "$mean": "ctr" }
      examples:
        - { "$mean": "ctr" }
        - { "$mean": { "$freqP": { "f": "clicks", "n": "impressions" } } }
      type: object
      properties:
        $mean:
          $ref: "#/components/schemas/Score"
    "DeleteOperation":
      type: object
      example: {
        "from": "user",
        "where": {
          "id": 4
        }
      }
      required:
        - "from"
        - "where"
      properties:
        "from":
          example: "user"
          $ref: "#/components/schemas/FromTablemodify"
          description: The modified table
        "where":
          example: {
            "id": 4
          }
          $ref: "#/components/schemas/Proposition"
          description: The entries to delete
    "RenameTableOperation":
      type: object
      example: {
        "from": "old_table",
        "rename": "new_table"
      }
      required:
        - "from"
        - "rename"
      properties:
        "from":
          example: "old_table"
          $ref: "#/components/schemas/FromTablemodify"
          description: The table to rename
        "rename":
          example: "new_table"
          $ref: "#/components/schemas/FromTablemodify"
          description: The name of the renamed table
        "replace":
          type: boolean
          description: If replace is true, operation will overwrite any existing table
          default: false
    "MinScore":
      example: {
        "$min": {
          "$context": "score"
        }
      }

      type: object
      properties:
        $min:
          $ref: "#/components/schemas/ContextValueQuery"
    "LteExplanation":
      type: object
      properties:
        $lte:
          oneOf:
            - $ref: "#/components/schemas/IntArray"
            - $ref: "#/components/schemas/LongArray"
            - $ref: "#/components/schemas/DecimalArray"
            - $ref: "#/components/schemas/StringArray"
            - $ref: "#/components/schemas/BooleanArray"
            - type: object
            - type: object
            - type: object
            - type: object
            - type: object
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: boolean
            - type: "null"
            - type: string
            - type: object
    "Frequency":
      example: "$f"
      examples:
        - "$f"
        - {
          "from": "impressions",
          "get": "product",
          "orderBy": "$f"
        }
      type: string
      enum: ["$f"]
    "HasExplanation":
      type: object
      properties:
        $has:
          oneOf:
            - $ref: "#/components/schemas/IntArray"
            - $ref: "#/components/schemas/LongArray"
            - $ref: "#/components/schemas/DecimalArray"
            - $ref: "#/components/schemas/StringArray"
            - $ref: "#/components/schemas/BooleanArray"
            - type: object
            - type: object
            - type: object
            - type: object
            - type: object
            - type: integer
              format: int32
            - type: integer
              format: int64
            - type: number
            - type: boolean
            - type: "null"
            - type: string
            - type: object
    "Or":
      example: { "$or": [{ "tags": "cover" }, { "tags": "laptop" }] }
      examples:
        - { "$or": [{ "tags": "cover" }, { "tags": "laptop" }] }
        - {
          "from": "products",
          "where": {
            "price": {
              "$or": [
                { "$lt": 0.9 },
                { "$gt": 2.1 }
              ]
            }
          }
        }
      type: object
      properties:
        $or:
          type: array
          items:
            oneOf:
              - $ref: "#/components/schemas/Proposition"
              - $ref: "#/components/schemas/PrimitiveProposition"
    "Hash":
      example: { "$hash": { "$mod": [2, 1] } }
      type: object
      properties:
        $hash:
          oneOf:
            - $ref: "#/components/schemas/Proposition"
            - $ref: "#/components/schemas/PrimitiveProposition"
    "Projection":
      oneOf:
        - $ref: "#/components/schemas/ProjectionList"
        - $ref: "#/components/schemas/IndexProjection"
        - $ref: "#/components/schemas/RankProjection"
        - $ref: "#/components/schemas/ParametricWhy"
        - $ref: "#/components/schemas/ParametricHighlight"
        - $ref: "#/components/schemas/HighlightProjection"
        - $ref: "#/components/schemas/ParametricMatches"
        - $ref: "#/components/schemas/MatchesProjection"
        - $ref: "#/components/schemas/Expand"
        - $ref: "#/components/schemas/ScoreOperator"
        - $ref: "#/components/schemas/ProjectionField"
        - $ref: "#/components/schemas/NamedProjection"
    "ParametricHighlight":
      example: {
        "$highlight": {
          "posPreTag": "<b>",
          "posPostTag": "</b>",
          "negPreTag": "<em>",
          "negPostTag": "</em>",
          "encoder": "html"
        }
      }
      type: object
      properties:
        $highlight:
          type: object
          properties:
            "posPreTag":
              type: string
            "posPostTag":
              type: string
            "negPreTag":
              type: string
            "negPostTag":
              type: string
            "posThreshold":
              type: number
            "negThreshold":
              type: number
            "encoder":
              type: string
