Search

POST/api/v1/_search

Find by id

Request body

{
  "from": "products",
  "where": {
    "id": "6411300000494"
  }
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_search \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": { "id": "6411300000494" }
  }'

Response

{
  "offset": 0,
  "total": 1,
  "hits": [
    {
      "category": "108",
      "cost": 2.765,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6411300000494",
      "name": "Juhla Mokka coffee 500g sj",
      "price": 3.95,
      "tags": [
        "coffee"
      ]
    }
  ]
}

Where price is greater than

Request body

{
  "from": "products",
  "where": {
    "price": {
      "$gt": 1.5
    }
  },
  "limit": 2
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_search \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": {
      "price": { "$gt": 1.5 }
    },
    "limit": 2
  }'

Response

{
  "offset": 0,
  "total": 21,
  "hits": [
    {
      "category": "101",
      "cost": 1.183,
      "googleClicks": 12,
      "googleImpressions": 100,
      "id": "6437002001454",
      "name": "VAASAN Ruispalat 660g 12 pcs fullcorn rye bread",
      "price": 1.69,
      "tags": [
        "gluten",
        "bread"
      ]
    },
    {
      "category": "101",
      "cost": 1.295,
      "googleClicks": 11,
      "googleImpressions": 100,
      "id": "6411402202208",
      "name": "Fazer Puikula fullcorn rye bread 9 pcs/500g",
      "price": 1.85,
      "tags": [
        "gluten",
        "bread"
      ]
    }
  ]
}

Find products with search term

Request body

{
  "from": "products",
  "where": {
    "name": {
      "$match": "coffee"
    }
  }
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_search \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": {
      "name": { "$match": "coffee" }
    }
  }'

Response

{
  "offset": 0,
  "total": 4,
  "hits": [
    {
      "category": "108",
      "cost": 2.765,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6411300000494",
      "name": "Juhla Mokka coffee 500g sj",
      "price": 3.95,
      "tags": [
        "coffee"
      ]
    },
    {
      "category": "108",
      "cost": 2.415,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "6420101441542",
      "name": "Kulta Katriina filter coffee 500g",
      "price": 3.45,
      "tags": [
        "coffee"
      ]
    },
    {
      "category": "108",
      "cost": 2.765,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6411300164653",
      "name": "Juhla Mokka Dark Roast coffee 500g hj",
      "price": 3.95,
      "tags": [
        "coffee"
      ]
    },
    {
      "category": "108",
      "cost": 2.023,
      "googleClicks": 7,
      "googleImpressions": 100,
      "id": "6410405181190",
      "name": "Pirkka Costa Rica filter coffee 500g UTZ",
      "price": 2.89,
      "tags": [
        "coffee",
        "pirkka"
      ]
    }
  ]
}

More complex where proposition

Request body

{
  "from": "products",
  "where": {
    "$and": [
      {
        "$or": [
          {
            "tags": {
              "$has": "drink"
            }
          },
          {
            "name": {
              "$match": "coffee"
            }
          }
        ]
      },
      {
        "price": {
          "$gt": 1.5
        }
      }
    ]
  },
  "limit": 2
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_search \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": {
      "$and": [
        {
          "$or": [
            {
              "tags": { "$has": "drink" }
            },
            {
              "name": { "$match": "coffee" }
            }
          ]
        },
        {
          "price": { "$gt": 1.5 }
        }
      ]
    },
    "limit": 2
  }'

Response

{
  "offset": 0,
  "total": 6,
  "hits": [
    {
      "category": "104",
      "cost": 1.365,
      "googleClicks": 8,
      "googleImpressions": 100,
      "id": "6408430000258",
      "name": "Valio eilaβ„’ Lactose-free semi-skimmed milk drink 1l",
      "price": 1.95,
      "tags": [
        "lactose-free",
        "drink"
      ]
    },
    {
      "category": "108",
      "cost": 2.765,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6411300000494",
      "name": "Juhla Mokka coffee 500g sj",
      "price": 3.95,
      "tags": [
        "coffee"
      ]
    }
  ]
}

Predict

POST/api/v1/_predict

Predict invoice processor

Request body

{
  "from": "invoices",
  "where": {
    "ProductName": "Cloud Services (AWS)"
  },
  "predict": "Processor"
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_predict \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "invoices",
    "where": { "ProductName": "Cloud Services (AWS)" },
    "predict": "Processor"
  }'

Response

{
  "offset": 0,
  "total": 10,
  "hits": [
    {
      "$p": 0.8390388336961537,
      "Department": "IT & Infrastructure",
      "Name": "Carol White",
      "Role": "IT Manager",
      "Superior": "Bob Brown"
    },
    {
      "$p": 0.09836635553989266,
      "Department": "IT & Infrastructure",
      "Name": "Evelyn Carter",
      "Role": "IT Manager",
      "Superior": "Bob Brown"
    },
    {
      "$p": 0.039006000349656914,
      "Department": "Retail",
      "Name": "David Green",
      "Role": "Store Manager",
      "Superior": "Alice Johnson"
    },
    {
      "$p": 0.016862164808146382,
      "Department": "Finance",
      "Name": "Emily Davis",
      "Role": "Finance Manager",
      "Superior": "Jane Smith"
    },
    {
      "$p": 0.0011211076010250744,
      "Department": "Executive",
      "Name": "John Doe",
      "Role": "CEO"
    },
    {
      "$p": 0.0011211076010250744,
      "Department": "Finance",
      "Name": "Jane Smith",
      "Role": "CFO",
      "Superior": "John Doe"
    },
    {
      "$p": 0.0011211076010250744,
      "Department": "Operations",
      "Name": "Alice Johnson",
      "Role": "COO",
      "Superior": "John Doe"
    },
    {
      "$p": 0.0011211076010250744,
      "Department": "IT & Infrastructure",
      "Name": "Bob Brown",
      "Role": "CTO",
      "Superior": "John Doe"
    },
    {
      "$p": 0.0011211076010250744,
      "Department": "Operations",
      "Name": "Frank Wilson",
      "Role": "Operations Manager",
      "Superior": "Alice Johnson"
    },
    {
      "$p": 0.0011211076010250744,
      "Department": "Support",
      "Name": "Bob Smith",
      "Role": "Support Manager",
      "Superior": "Frank Wilson"
    }
  ]
}

Explain the prediction

Request body

{
  "from": "invoices",
  "where": {
    "ProductName": "Cloud Services (AWS)"
  },
  "select": [
    "$why"
  ],
  "predict": "Processor"
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_predict \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "invoices",
    "where": { "ProductName": "Cloud Services (AWS)" },
    "select": ["$why"],
    "predict": "Processor"
  }'

Response

{
  "offset": 0,
  "total": 10,
  "hits": [
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.27927927927927926,
            "proposition": {
              "Processor": {
                "$has": "Carol White"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 1.0556476570945323
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 2.8536855643127392
          }
        ]
      }
    },
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.018018018018018018,
            "proposition": {
              "Processor": {
                "$has": "Evelyn Carter"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 0.9869823146297666
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 5.546409780594337
          }
        ]
      }
    },
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.4594594594594595,
            "proposition": {
              "Processor": {
                "$has": "David Green"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 0.939673370175257
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 0.09059183635801255
          }
        ]
      }
    },
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.1891891891891892,
            "proposition": {
              "Processor": {
                "$has": "Emily Davis"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 0.9864422871310281
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 0.09059976930910794
          }
        ]
      }
    },
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.047619047619047616,
            "proposition": {
              "Processor": {
                "$has": "John Doe"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 1.0394895135054398
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 0.022710580688655616
          }
        ]
      }
    },
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.047619047619047616,
            "proposition": {
              "Processor": {
                "$has": "Jane Smith"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 1.0394895135054398
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 0.022710580688655616
          }
        ]
      }
    },
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.047619047619047616,
            "proposition": {
              "Processor": {
                "$has": "Alice Johnson"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 1.0394895135054398
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 0.022710580688655616
          }
        ]
      }
    },
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.047619047619047616,
            "proposition": {
              "Processor": {
                "$has": "Bob Brown"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 1.0394895135054398
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 0.022710580688655616
          }
        ]
      }
    },
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.047619047619047616,
            "proposition": {
              "Processor": {
                "$has": "Frank Wilson"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 1.0394895135054398
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 0.022710580688655616
          }
        ]
      }
    },
    {
      "$why": {
        "type": "product",
        "factors": [
          {
            "type": "baseP",
            "value": 0.047619047619047616,
            "proposition": {
              "Processor": {
                "$has": "Bob Smith"
              }
            }
          },
          {
            "type": "product",
            "factors": [
              {
                "type": "normalizer",
                "name": "exclusiveness",
                "value": 0.9972825969189799
              },
              {
                "type": "normalizer",
                "name": "trueFalseExclusiveness",
                "value": 1.0394895135054398
              }
            ]
          },
          {
            "type": "relatedPropositionLift",
            "proposition": {
              "$and": [
                {
                  "ProductName": {
                    "$has": "cloud"
                  }
                },
                {
                  "ProductName": {
                    "$has": "servic"
                  }
                },
                {
                  "ProductName": {
                    "$has": "aw"
                  }
                }
              ]
            },
            "value": 0.022710580688655616
          }
        ]
      }
    }
  ]
}

Example request

Request body

{
  "from": "products",
  "where": {
    "name": "Hovis Seed Sensations Seven Seeds Original 800g"
  },
  "predict": "tags",
  "exclusiveness": false,
  "limit": 3
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_predict \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": { "name": "Hovis Seed Sensations Seven Seeds Original 800g" },
    "predict": "tags",
    "exclusiveness": false,
    "limit": 3
  }'

Response

{
  "offset": 0,
  "total": 25,
  "hits": [
    {
      "$p": 0.3409090909090909,
      "field": "tags",
      "feature": "pirkka"
    },
    {
      "$p": 0.29545454545454547,
      "field": "tags",
      "feature": "food"
    },
    {
      "$p": 0.25,
      "field": "tags",
      "feature": "meat"
    }
  ]
}

Example request

Request body

{
  "from": "invoices",
  "where": {
    "ProductName": "Cloud Services (AWS)",
    "Description": "For IT Department"
  },
  "predict": "Processor",
  "limit": 3
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_predict \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "invoices",
    "where": {
      "ProductName": "Cloud Services (AWS)",
      "Description": "For IT Department"
    },
    "predict": "Processor",
    "limit": 3
  }'

Response

{
  "offset": 0,
  "total": 10,
  "hits": [
    {
      "$p": 0.8390388336961537,
      "Department": "IT & Infrastructure",
      "Name": "Carol White",
      "Role": "IT Manager",
      "Superior": "Bob Brown"
    },
    {
      "$p": 0.09836635553989266,
      "Department": "IT & Infrastructure",
      "Name": "Evelyn Carter",
      "Role": "IT Manager",
      "Superior": "Bob Brown"
    },
    {
      "$p": 0.039006000349656914,
      "Department": "Retail",
      "Name": "David Green",
      "Role": "Store Manager",
      "Superior": "Alice Johnson"
    }
  ]
}

Example request

Request body

{
  "from": "invoices",
  "where": {
    "ProductName": "Cloud Services (AWS)",
    "Description": "For IT Department",
    "Processor.Department": "IT & Infrastructure"
  },
  "predict": "Processor",
  "basedOn": [
    "Role"
  ],
  "limit": 3
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_predict \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "invoices",
    "where": {
      "ProductName": "Cloud Services (AWS)",
      "Description": "For IT Department",
      "Processor.Department": "IT & Infrastructure"
    },
    "predict": "Processor",
    "basedOn": ["Role"],
    "limit": 3
  }'

Response

{
  "offset": 0,
  "total": 3,
  "hits": [
    {
      "$p": 0.8625093721609497,
      "Department": "IT & Infrastructure",
      "Name": "Carol White",
      "Role": "IT Manager",
      "Superior": "Bob Brown"
    },
    {
      "$p": 0.12005283360271811,
      "Department": "IT & Infrastructure",
      "Name": "Evelyn Carter",
      "Role": "IT Manager",
      "Superior": "Bob Brown"
    },
    {
      "$p": 0.01743779423633219,
      "Department": "IT & Infrastructure",
      "Name": "Bob Brown",
      "Role": "CTO",
      "Superior": "John Doe"
    }
  ]
}

Recommend

POST/api/v1/_recommend

Recommend top 5 products for a customer

Request body

{
  "from": "impressions",
  "where": {
    "context.user": "veronica"
  },
  "recommend": "product",
  "goal": {
    "purchase": true
  },
  "limit": 5
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_recommend \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "impressions",
    "where": { "context.user": "veronica" },
    "recommend": "product",
    "goal": { "purchase": true },
    "limit": 5
  }'

Response

{
  "offset": 0,
  "total": 42,
  "hits": [
    {
      "$p": 0.5750580301278168,
      "category": "100",
      "cost": 0.774,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "6410405093677",
      "name": "Pirkka iceberg salad Finland 100g 1st class",
      "price": 1.29,
      "tags": [
        "fresh",
        "vegetable",
        "pirkka",
        "salad"
      ]
    },
    {
      "$p": 0.531656910457125,
      "category": "100",
      "cost": 0.586,
      "googleClicks": 11,
      "googleImpressions": 100,
      "id": "2000604700007",
      "name": "Cucumber Finland",
      "price": 0.9765,
      "tags": [
        "fresh",
        "vegetable"
      ]
    },
    {
      "$p": 0.4817731584887589,
      "category": "100",
      "cost": 0.1,
      "googleClicks": 12,
      "googleImpressions": 100,
      "id": "2000818700008",
      "name": "Pirkka banana",
      "price": 0.166,
      "tags": [
        "fresh",
        "fruit",
        "pirkka"
      ]
    },
    {
      "$p": 0.4297210192015707,
      "category": "100",
      "cost": 0.168,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "2000503600002",
      "name": "Chiquita banana",
      "price": 0.28054,
      "tags": [
        "fresh",
        "fruit"
      ]
    },
    {
      "$p": 0.3893056368583821,
      "category": "111",
      "cost": 1.61,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6414880021620",
      "name": "Ilta Sanomat weekend news",
      "price": 2.3,
      "tags": [
        "news"
      ]
    }
  ]
}

Recommend top products with additional filtering

Request body

{
  "from": "impressions",
  "where": {
    "product.name": {
      "$match": "Banana"
    },
    "context.user": "veronica"
  },
  "recommend": "product",
  "goal": {
    "purchase": true
  },
  "limit": 5
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_recommend \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "impressions",
    "where": {
      "product.name": { "$match": "Banana" },
      "context.user": "veronica"
    },
    "recommend": "product",
    "goal": { "purchase": true },
    "limit": 5
  }'

Response

{
  "offset": 0,
  "total": 2,
  "hits": [
    {
      "$p": 0.4817731584887589,
      "category": "100",
      "cost": 0.1,
      "googleClicks": 12,
      "googleImpressions": 100,
      "id": "2000818700008",
      "name": "Pirkka banana",
      "price": 0.166,
      "tags": [
        "fresh",
        "fruit",
        "pirkka"
      ]
    },
    {
      "$p": 0.4297210192015707,
      "category": "100",
      "cost": 0.168,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "2000503600002",
      "name": "Chiquita banana",
      "price": 0.28054,
      "tags": [
        "fresh",
        "fruit"
      ]
    }
  ]
}

Estimate

POST/api/v1/_estimate

Estimate product price

Request body

{
  "from": "products",
  "where": {
    "tags": {
      "$has": "bread"
    }
  },
  "estimate": "price",
  "select": [
    "estimate"
  ]
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_estimate \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": {
      "tags": { "$has": "bread" }
    },
    "estimate": "price",
    "select": ["estimate"]
  }'

Response

{
  "estimate": 1.350545069703815
}

Estimate product price

Request body

{
  "from": "products",
  "where": {
    "tags": {
      "$has": "bread"
    }
  },
  "estimate": "price",
  "model": "regression",
  "select": [
    "estimate"
  ]
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_estimate \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": {
      "tags": { "$has": "bread" }
    },
    "estimate": "price",
    "model": "regression",
    "select": ["estimate"]
  }'

Response

{
  "estimate": 1.350545069703815
}

Estimate with explanation

Request body

{
  "from": "products",
  "where": {
    "tags": {
      "$has": "bread"
    }
  },
  "estimate": "price",
  "model": "regression",
  "select": [
    "estimate",
    "why"
  ]
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_estimate \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": {
      "tags": { "$has": "bread" }
    },
    "estimate": "price",
    "model": "regression",
    "select": ["estimate", "why"]
  }'

Response

{
  "estimate": 1.350545069703815,
  "why": {
    "type": "exponent",
    "value": 1.3505450697038148,
    "base": {
      "type": "constant",
      "value": 2.718281828459045
    },
    "power": {
      "type": "sum",
      "terms": [
        {
          "type": "input",
          "name": "residual",
          "value": 0
        },
        {
          "type": "mean centering",
          "name": "mean",
          "value": 0.30050826629924476
        }
      ]
    }
  }
}

Estimate with explanation

Request body

{
  "from": "price_history",
  "where": {
    "product_id": "2000818700008",
    "day_of_week": "Friday",
    "competitor_avg_price": 0.18,
    "sale_price": 0.16
  },
  "estimate": "units_sold",
  "select": [
    "estimate"
  ]
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_estimate \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "price_history",
    "where": {
      "product_id": "2000818700008",
      "day_of_week": "Friday",
      "competitor_avg_price": 0.18,
      "sale_price": 0.16
    },
    "estimate": "units_sold",
    "select": ["estimate"]
  }'

Response

{
  "estimate": 242.74868764966547
}

Evaluate

POST/api/v1/_evaluate

Example request

Request body

{
  "test": {
    "$index": {
      "$mod": [
        4,
        0
      ]
    }
  },
  "evaluate": {
    "from": "products",
    "where": {
      "name": {
        "$match": {
          "$get": "name"
        }
      }
    },
    "predict": "category"
  }
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_evaluate \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "test": {
      "$index": {
        "$mod": [4, 0]
      }
    },
    "evaluate": {
      "from": "products",
      "where": {
        "name": {
          "$match": { "$get": "name" }
        }
      },
      "predict": "category"
    }
  }'

Response

{
  "n": 11,
  "testSamples": 11,
  "trainSamples": 31,
  "features": 235,
  "error": 0.2727272727272727,
  "baseError": 0.9090909090909091,
  "accuracy": 0.7272727272727273,
  "baseAccuracy": 0.09090909090909091,
  "accuracyGain": 0.6363636363636364,
  "meanRank": 1.2727272727272727,
  "baseMeanRank": 4.090909090909091,
  "rankGain": 2.8181818181818183,
  "informationGain": 1.7614234118799088,
  "mxe": 1.5892906126268733,
  "h": 3.350714024506782,
  "geomMeanP": 0.3323348256647959,
  "baseGmp": 0.09802448555185775,
  "geomMeanLift": 3.3903246091404506,
  "meanNs": 24934332.09090909,
  "meanUs": 24934.33209090909,
  "meanMs": 24.93433209090909,
  "medianNs": 24764423,
  "medianUs": 24764.423,
  "medianMs": 24.764423,
  "allNs": [
    35714409,
    30766844,
    26229868,
    24962306,
    13546611,
    21921548,
    42341744,
    24764423,
    19674929,
    16305083,
    18049888
  ],
  "allUs": [
    35714,
    30766,
    26229,
    24962,
    13546,
    21921,
    42341,
    24764,
    19674,
    16305,
    18049
  ],
  "allMs": [
    35,
    30,
    26,
    24,
    13,
    21,
    42,
    24,
    19,
    16,
    18
  ],
  "warmingMs": 10,
  "accurateOffsets": [
    0,
    1,
    2,
    4,
    5,
    6,
    7,
    8
  ],
  "errorOffsets": [
    3,
    9,
    10
  ],
  "cases": [
    {
      "offset": 0,
      "testCase": {
        "category": "100",
        "cost": 0.1,
        "googleClicks": 12,
        "googleImpressions": 100,
        "id": "2000818700008",
        "name": "Pirkka banana",
        "price": 0.166,
        "tags": [
          "fresh",
          "fruit",
          "pirkka"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.320114888093063,
        "field": "category",
        "feature": "100"
      },
      "correct": {
        "$p": 0.320114888093063,
        "field": "category",
        "feature": "100"
      }
    },
    {
      "offset": 1,
      "testCase": {
        "category": "100",
        "cost": 0.774,
        "googleClicks": 9,
        "googleImpressions": 100,
        "id": "6410405093677",
        "name": "Pirkka iceberg salad Finland 100g 1st class",
        "price": 1.29,
        "tags": [
          "fresh",
          "vegetable",
          "pirkka",
          "salad"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.320114888093063,
        "field": "category",
        "feature": "100"
      },
      "correct": {
        "$p": 0.320114888093063,
        "field": "category",
        "feature": "100"
      }
    },
    {
      "offset": 2,
      "testCase": {
        "category": "101",
        "cost": 0.903,
        "googleClicks": 9,
        "googleImpressions": 100,
        "id": "6413467282508",
        "name": "Fazer Puikula fullcorn rye bread 330g",
        "price": 1.29,
        "tags": [
          "gluten",
          "bread"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.7987972939135833,
        "field": "category",
        "feature": "101"
      },
      "correct": {
        "$p": 0.7987972939135833,
        "field": "category",
        "feature": "101"
      }
    },
    {
      "offset": 3,
      "testCase": {
        "category": "102",
        "cost": 1.953,
        "googleClicks": 10,
        "googleImpressions": 100,
        "id": "6410405205483",
        "name": "Pirkka Finnish beef-pork minced meat 20% 400g",
        "price": 2.79,
        "tags": [
          "meat",
          "food",
          "protein",
          "pirkka"
        ]
      },
      "accurate": false,
      "top": {
        "$p": 0.25550150530501686,
        "field": "category",
        "feature": "104"
      },
      "correct": {
        "$p": 0.05185168612341176,
        "field": "category",
        "feature": "102"
      }
    },
    {
      "offset": 4,
      "testCase": {
        "category": "103",
        "cost": 1.393,
        "googleClicks": 11,
        "googleImpressions": 100,
        "id": "6412000030026",
        "name": "Saarioinen Maksalaatikko liver casserole 400g",
        "price": 1.99,
        "tags": [
          "meat",
          "food"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.2636318834456787,
        "field": "category",
        "feature": "103"
      },
      "correct": {
        "$p": 0.2636318834456787,
        "field": "category",
        "feature": "103"
      }
    },
    {
      "offset": 5,
      "testCase": {
        "category": "104",
        "cost": 0.567,
        "googleClicks": 12,
        "googleImpressions": 100,
        "id": "6410405082657",
        "name": "Pirkka Finnish semi-skimmed milk 1l",
        "price": 0.81,
        "tags": [
          "lactose",
          "drink",
          "pirkka"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.7520226972878733,
        "field": "category",
        "feature": "104"
      },
      "correct": {
        "$p": 0.7520226972878733,
        "field": "category",
        "feature": "104"
      }
    },
    {
      "offset": 6,
      "testCase": {
        "category": "104",
        "cost": 1.365,
        "googleClicks": 8,
        "googleImpressions": 100,
        "id": "6408430000258",
        "name": "Valio eilaβ„’ Lactose-free semi-skimmed milk drink 1l",
        "price": 1.95,
        "tags": [
          "lactose-free",
          "drink"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.9071325597427301,
        "field": "category",
        "feature": "104"
      },
      "correct": {
        "$p": 0.9071325597427301,
        "field": "category",
        "feature": "104"
      }
    },
    {
      "offset": 7,
      "testCase": {
        "category": "108",
        "cost": 2.415,
        "googleClicks": 9,
        "googleImpressions": 100,
        "id": "6420101441542",
        "name": "Kulta Katriina filter coffee 500g",
        "price": 3.45,
        "tags": [
          "coffee"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.8193994302412899,
        "field": "category",
        "feature": "108"
      },
      "correct": {
        "$p": 0.8193994302412899,
        "field": "category",
        "feature": "108"
      }
    },
    {
      "offset": 8,
      "testCase": {
        "category": "109",
        "cost": 1.533,
        "googleClicks": 10,
        "googleImpressions": 100,
        "id": "6411401015090",
        "name": "Fazer Sininen milk chocolate slab 200g",
        "price": 2.19,
        "tags": [
          "candy",
          "lactose"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.8334364256405865,
        "field": "category",
        "feature": "109"
      },
      "correct": {
        "$p": 0.8334364256405865,
        "field": "category",
        "feature": "109"
      }
    },
    {
      "offset": 9,
      "testCase": {
        "category": "111",
        "cost": 2.345,
        "googleClicks": 11,
        "googleImpressions": 100,
        "id": "6413200330206",
        "name": "Lotus Soft Embo 8 rll toilet paper",
        "price": 3.35,
        "tags": [
          "toilet-paper"
        ]
      },
      "accurate": false,
      "top": {
        "$p": 0.2770604820366743,
        "field": "category",
        "feature": "108"
      },
      "correct": {
        "$p": 0.24962318794613386,
        "field": "category",
        "feature": "111"
      }
    },
    {
      "offset": 10,
      "testCase": {
        "category": "115",
        "cost": 1.183,
        "googleClicks": 10,
        "googleImpressions": 100,
        "id": "6410402010318",
        "name": "Pirkka tuna fish pieces in oil 200g/150g",
        "price": 1.69,
        "tags": [
          "meat",
          "food",
          "protein",
          "pirkka"
        ]
      },
      "accurate": false,
      "top": {
        "$p": 0.27380293267902256,
        "field": "category",
        "feature": "103"
      },
      "correct": {
        "$p": 0.0419730453318052,
        "field": "category",
        "feature": "115"
      }
    }
  ],
  "accurateCases": [
    {
      "offset": 0,
      "testCase": {
        "category": "100",
        "cost": 0.1,
        "googleClicks": 12,
        "googleImpressions": 100,
        "id": "2000818700008",
        "name": "Pirkka banana",
        "price": 0.166,
        "tags": [
          "fresh",
          "fruit",
          "pirkka"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.320114888093063,
        "field": "category",
        "feature": "100"
      },
      "correct": {
        "$p": 0.320114888093063,
        "field": "category",
        "feature": "100"
      }
    },
    {
      "offset": 1,
      "testCase": {
        "category": "100",
        "cost": 0.774,
        "googleClicks": 9,
        "googleImpressions": 100,
        "id": "6410405093677",
        "name": "Pirkka iceberg salad Finland 100g 1st class",
        "price": 1.29,
        "tags": [
          "fresh",
          "vegetable",
          "pirkka",
          "salad"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.320114888093063,
        "field": "category",
        "feature": "100"
      },
      "correct": {
        "$p": 0.320114888093063,
        "field": "category",
        "feature": "100"
      }
    },
    {
      "offset": 2,
      "testCase": {
        "category": "101",
        "cost": 0.903,
        "googleClicks": 9,
        "googleImpressions": 100,
        "id": "6413467282508",
        "name": "Fazer Puikula fullcorn rye bread 330g",
        "price": 1.29,
        "tags": [
          "gluten",
          "bread"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.7987972939135833,
        "field": "category",
        "feature": "101"
      },
      "correct": {
        "$p": 0.7987972939135833,
        "field": "category",
        "feature": "101"
      }
    },
    {
      "offset": 4,
      "testCase": {
        "category": "103",
        "cost": 1.393,
        "googleClicks": 11,
        "googleImpressions": 100,
        "id": "6412000030026",
        "name": "Saarioinen Maksalaatikko liver casserole 400g",
        "price": 1.99,
        "tags": [
          "meat",
          "food"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.2636318834456787,
        "field": "category",
        "feature": "103"
      },
      "correct": {
        "$p": 0.2636318834456787,
        "field": "category",
        "feature": "103"
      }
    },
    {
      "offset": 5,
      "testCase": {
        "category": "104",
        "cost": 0.567,
        "googleClicks": 12,
        "googleImpressions": 100,
        "id": "6410405082657",
        "name": "Pirkka Finnish semi-skimmed milk 1l",
        "price": 0.81,
        "tags": [
          "lactose",
          "drink",
          "pirkka"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.7520226972878733,
        "field": "category",
        "feature": "104"
      },
      "correct": {
        "$p": 0.7520226972878733,
        "field": "category",
        "feature": "104"
      }
    },
    {
      "offset": 6,
      "testCase": {
        "category": "104",
        "cost": 1.365,
        "googleClicks": 8,
        "googleImpressions": 100,
        "id": "6408430000258",
        "name": "Valio eilaβ„’ Lactose-free semi-skimmed milk drink 1l",
        "price": 1.95,
        "tags": [
          "lactose-free",
          "drink"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.9071325597427301,
        "field": "category",
        "feature": "104"
      },
      "correct": {
        "$p": 0.9071325597427301,
        "field": "category",
        "feature": "104"
      }
    },
    {
      "offset": 7,
      "testCase": {
        "category": "108",
        "cost": 2.415,
        "googleClicks": 9,
        "googleImpressions": 100,
        "id": "6420101441542",
        "name": "Kulta Katriina filter coffee 500g",
        "price": 3.45,
        "tags": [
          "coffee"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.8193994302412899,
        "field": "category",
        "feature": "108"
      },
      "correct": {
        "$p": 0.8193994302412899,
        "field": "category",
        "feature": "108"
      }
    },
    {
      "offset": 8,
      "testCase": {
        "category": "109",
        "cost": 1.533,
        "googleClicks": 10,
        "googleImpressions": 100,
        "id": "6411401015090",
        "name": "Fazer Sininen milk chocolate slab 200g",
        "price": 2.19,
        "tags": [
          "candy",
          "lactose"
        ]
      },
      "accurate": true,
      "top": {
        "$p": 0.8334364256405865,
        "field": "category",
        "feature": "109"
      },
      "correct": {
        "$p": 0.8334364256405865,
        "field": "category",
        "feature": "109"
      }
    }
  ],
  "errorCases": [
    {
      "offset": 3,
      "testCase": {
        "category": "102",
        "cost": 1.953,
        "googleClicks": 10,
        "googleImpressions": 100,
        "id": "6410405205483",
        "name": "Pirkka Finnish beef-pork minced meat 20% 400g",
        "price": 2.79,
        "tags": [
          "meat",
          "food",
          "protein",
          "pirkka"
        ]
      },
      "accurate": false,
      "top": {
        "$p": 0.25550150530501686,
        "field": "category",
        "feature": "104"
      },
      "correct": {
        "$p": 0.05185168612341176,
        "field": "category",
        "feature": "102"
      }
    },
    {
      "offset": 9,
      "testCase": {
        "category": "111",
        "cost": 2.345,
        "googleClicks": 11,
        "googleImpressions": 100,
        "id": "6413200330206",
        "name": "Lotus Soft Embo 8 rll toilet paper",
        "price": 3.35,
        "tags": [
          "toilet-paper"
        ]
      },
      "accurate": false,
      "top": {
        "$p": 0.2770604820366743,
        "field": "category",
        "feature": "108"
      },
      "correct": {
        "$p": 0.24962318794613386,
        "field": "category",
        "feature": "111"
      }
    },
    {
      "offset": 10,
      "testCase": {
        "category": "115",
        "cost": 1.183,
        "googleClicks": 10,
        "googleImpressions": 100,
        "id": "6410402010318",
        "name": "Pirkka tuna fish pieces in oil 200g/150g",
        "price": 1.69,
        "tags": [
          "meat",
          "food",
          "protein",
          "pirkka"
        ]
      },
      "accurate": false,
      "top": {
        "$p": 0.27380293267902256,
        "field": "category",
        "feature": "103"
      },
      "correct": {
        "$p": 0.0419730453318052,
        "field": "category",
        "feature": "115"
      }
    }
  ],
  "alpha_binByTopScore": [
    {
      "meanScore": 0.2674992008665981,
      "maxScore": 0.2770604820366743,
      "minScore": 0.25550150530501686,
      "accuracy": 0.25,
      "n": 4,
      "accurateOffsets": [
        4
      ],
      "errorOffsets": [
        3,
        10,
        9
      ]
    },
    {
      "meanScore": 0.5477624418468956,
      "maxScore": 0.7987972939135833,
      "minScore": 0.320114888093063,
      "accuracy": 1,
      "n": 4,
      "accurateOffsets": [
        0,
        1,
        5,
        2
      ],
      "errorOffsets": []
    },
    {
      "meanScore": 0.8533228052082023,
      "maxScore": 0.9071325597427301,
      "minScore": 0.8193994302412899,
      "accuracy": 1,
      "n": 3,
      "accurateOffsets": [
        7,
        8,
        6
      ],
      "errorOffsets": []
    }
  ]
}

Similarity

POST/api/v1/_similarity

Example request

Request body

{
  "from": "products",
  "similarity": {
    "category": "108",
    "id": "6411300000494",
    "name": "Juhla Mokka coffee 500g sj",
    "price": 3.95,
    "tags": [
      "coffee"
    ]
  },
  "limit": 3
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_similarity \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "similarity": {
      "category": "108",
      "id": "6411300000494",
      "name": "Juhla Mokka coffee 500g sj",
      "price": 3.95,
      "tags": ["coffee"]
    },
    "limit": 3
  }'

Response

{
  "offset": 0,
  "total": 42,
  "hits": [
    {
      "$score": 126.04566816298527,
      "category": "108",
      "cost": 2.765,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6411300000494",
      "name": "Juhla Mokka coffee 500g sj",
      "price": 3.95,
      "tags": [
        "coffee"
      ]
    },
    {
      "$score": 30.33799469334562,
      "category": "108",
      "cost": 2.765,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6411300164653",
      "name": "Juhla Mokka Dark Roast coffee 500g hj",
      "price": 3.95,
      "tags": [
        "coffee"
      ]
    },
    {
      "$score": 5.3239876815300375,
      "category": "108",
      "cost": 2.415,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "6420101441542",
      "name": "Kulta Katriina filter coffee 500g",
      "price": 3.45,
      "tags": [
        "coffee"
      ]
    }
  ]
}

Example request

Request body

{
  "from": "products",
  "similarity": {
    "name": "Hovis Seed Sensations Seven Seeds Original 800g"
  },
  "limit": 3
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_similarity \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "similarity": { "name": "Hovis Seed Sensations Seven Seeds Original 800g" },
    "limit": 3
  }'

Response

{
  "offset": 0,
  "total": 42,
  "hits": [
    {
      "$score": 1,
      "category": "100",
      "cost": 0.1,
      "googleClicks": 12,
      "googleImpressions": 100,
      "id": "2000818700008",
      "name": "Pirkka banana",
      "price": 0.166,
      "tags": [
        "fresh",
        "fruit",
        "pirkka"
      ]
    },
    {
      "$score": 1,
      "category": "100",
      "cost": 0.586,
      "googleClicks": 11,
      "googleImpressions": 100,
      "id": "2000604700007",
      "name": "Cucumber Finland",
      "price": 0.9765,
      "tags": [
        "fresh",
        "vegetable"
      ]
    },
    {
      "$score": 1,
      "category": "100",
      "cost": 0.774,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6410405060457",
      "name": "Pirkka bio cherry tomatoes 250g international 1lk",
      "price": 1.29,
      "tags": [
        "fresh",
        "vegetable",
        "pirkka",
        "tomato"
      ]
    }
  ]
}

Match

POST/api/v1/_match

Match user to products

Request body

{
  "from": "impressions",
  "where": {
    "context.user": "larry"
  },
  "match": "product",
  "limit": 5
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_match \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "impressions",
    "where": { "context.user": "larry" },
    "match": "product",
    "limit": 5
  }'

Response

{
  "offset": 0,
  "total": 42,
  "hits": [
    {
      "$p": 0.03166189371141542,
      "category": "100",
      "cost": 0.1,
      "googleClicks": 12,
      "googleImpressions": 100,
      "id": "2000818700008",
      "name": "Pirkka banana",
      "price": 0.166,
      "tags": [
        "fresh",
        "fruit",
        "pirkka"
      ]
    },
    {
      "$p": 0.03157541534006297,
      "category": "100",
      "cost": 0.586,
      "googleClicks": 11,
      "googleImpressions": 100,
      "id": "2000604700007",
      "name": "Cucumber Finland",
      "price": 0.9765,
      "tags": [
        "fresh",
        "vegetable"
      ]
    },
    {
      "$p": 0.03134840961526279,
      "category": "100",
      "cost": 0.774,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6410405060457",
      "name": "Pirkka bio cherry tomatoes 250g international 1lk",
      "price": 1.29,
      "tags": [
        "fresh",
        "vegetable",
        "pirkka",
        "tomato"
      ]
    },
    {
      "$p": 0.030667392440862258,
      "category": "100",
      "cost": 0.168,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "2000503600002",
      "name": "Chiquita banana",
      "price": 0.28054,
      "tags": [
        "fresh",
        "fruit"
      ]
    },
    {
      "$p": 0.03041876712322397,
      "category": "100",
      "cost": 0.774,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "6410405093677",
      "name": "Pirkka iceberg salad Finland 100g 1st class",
      "price": 1.29,
      "tags": [
        "fresh",
        "vegetable",
        "pirkka",
        "salad"
      ]
    }
  ]
}

Relate

POST/api/v1/_relate

What features of products affect purchasing

Request body

{
  "from": "impressions",
  "where": {
    "$exists": "product"
  },
  "relate": [
    {
      "purchase": true
    }
  ],
  "limit": 2
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_relate \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "impressions",
    "where": { "$exists": "product" },
    "relate": [
      { "purchase": true }
    ],
    "limit": 2
  }'

Response

{
  "offset": 0,
  "total": 2,
  "hits": [
    {
      "related": {
        "purchase": {
          "$has": true
        }
      },
      "condition": {
        "product": {
          "$has": "6414880021620"
        }
      },
      "lift": 2.7519515906117373,
      "fs": {
        "f": 4670,
        "fOnCondition": 277,
        "fOnNotCondition": 4393,
        "fCondition": 1942,
        "n": 90325
      },
      "ps": {
        "p": 0.05171211265734498,
        "pOnCondition": 0.14230923068127388,
        "pOnNotCondition": 0.049711351508249645,
        "pCondition": 0.02150017650007003
      },
      "info": {
        "h": 0.2936258448995185,
        "mi": 0.08358471092434532,
        "miTrue": 0.20783624057504413,
        "miFalse": -0.12425152965069881
      },
      "relation": {
        "n": 90325,
        "varFs": [
          1942,
          4670
        ],
        "stateFs": [
          83990,
          1665,
          4393,
          277
        ],
        "mi": 0.0018554250697989903
      }
    },
    {
      "related": {
        "purchase": {
          "$has": true
        }
      },
      "condition": {
        "product": {
          "$has": "2000818700008"
        }
      },
      "lift": 2.2022854429774776,
      "fs": {
        "f": 4670,
        "fOnCondition": 334,
        "fOnNotCondition": 4336,
        "fCondition": 2928,
        "n": 90325
      },
      "ps": {
        "p": 0.05171211265734498,
        "pOnCondition": 0.11388483293088221,
        "pOnNotCondition": 0.04961895380993485,
        "pCondition": 0.03241630546894901
      },
      "info": {
        "h": 0.2936258448995185,
        "mi": 0.043025554786315715,
        "miTrue": 0.1297149923290676,
        "miFalse": -0.0866894375427519
      },
      "relation": {
        "n": 90325,
        "varFs": [
          2928,
          4670
        ],
        "stateFs": [
          83061,
          2594,
          4336,
          334
        ],
        "mi": 0.0014579038683944189
      }
    }
  ]
}

Generic query

POST/api/v1/_query

Search query

Request body

{
  "from": "products",
  "where": {
    "id": "6410402010318"
  }
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_query \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": { "id": "6410402010318" }
  }'

Response

{
  "offset": 0,
  "total": 1,
  "hits": [
    {
      "category": "115",
      "cost": 1.183,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6410402010318",
      "name": "Pirkka tuna fish pieces in oil 200g/150g",
      "price": 1.69,
      "tags": [
        "meat",
        "food",
        "protein",
        "pirkka"
      ]
    }
  ]
}

Search query with highlighted results

Request body

{
  "from": "products",
  "where": {
    "name": {
      "$match": "coffee"
    }
  },
  "select": [
    "id",
    "name",
    "tags",
    "price",
    "$score",
    "$highlight"
  ],
  "orderBy": "$similarity"
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_query \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": {
      "name": { "$match": "coffee" }
    },
    "select": ["id", "name", "tags", "price", "$score", "$highlight"],
    "orderBy": "$similarity"
  }'

Response

{
  "offset": 0,
  "total": 4,
  "hits": [
    {
      "id": "6411300000494",
      "name": "Juhla Mokka coffee 500g sj",
      "tags": [
        "coffee"
      ],
      "price": 3.95,
      "$score": 2.1726635013471625,
      "$highlight": [
        {
          "score": 1.1194647495169912,
          "field": "name",
          "highlight": "Juhla Mokka <font color=\"green\">coffee</font> 500g sj"
        }
      ]
    },
    {
      "id": "6420101441542",
      "name": "Kulta Katriina filter coffee 500g",
      "tags": [
        "coffee"
      ],
      "price": 3.45,
      "$score": 2.1726635013471625,
      "$highlight": [
        {
          "score": 1.1194647495169912,
          "field": "name",
          "highlight": "Kulta Katriina filter <font color=\"green\">coffee</font> 500g"
        }
      ]
    },
    {
      "id": "6411300164653",
      "name": "Juhla Mokka Dark Roast coffee 500g hj",
      "tags": [
        "coffee"
      ],
      "price": 3.95,
      "$score": 2.1726635013471625,
      "$highlight": [
        {
          "score": 1.1194647495169912,
          "field": "name",
          "highlight": "Juhla Mokka Dark Roast <font color=\"green\">coffee</font> 500g hj"
        }
      ]
    },
    {
      "id": "6410405181190",
      "name": "Pirkka Costa Rica filter coffee 500g UTZ",
      "tags": [
        "coffee",
        "pirkka"
      ],
      "price": 2.89,
      "$score": 2.1726635013471625,
      "$highlight": [
        {
          "score": 1.1194647495169912,
          "field": "name",
          "highlight": "Pirkka Costa Rica filter <font color=\"green\">coffee</font> 500g UTZ"
        }
      ]
    }
  ]
}

Generic similarity query

Request body

{
  "from": "products",
  "orderBy": {
    "$similarity": {
      "name": "Atria bratwurst 175g"
    }
  },
  "limit": 2
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_query \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "orderBy": {
      "$similarity": { "name": "Atria bratwurst 175g" }
    },
    "limit": 2
  }'

Response

{
  "offset": 0,
  "total": 42,
  "hits": [
    {
      "$score": 2.1455611831385513,
      "category": "102",
      "cost": 0.623,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "6407870070333",
      "name": "Atria lauantaimakkara bread sausage 225g",
      "price": 0.89,
      "tags": [
        "meat",
        "sausage",
        "with-bread"
      ]
    },
    {
      "$score": 2.1455611831385513,
      "category": "102",
      "cost": 1.225,
      "googleClicks": 8,
      "googleImpressions": 100,
      "id": "6407870071224",
      "name": "Atria Gotler ham sausage 300g",
      "price": 1.75,
      "tags": [
        "meat",
        "sausage",
        "with-bread"
      ]
    }
  ]
}

Generic predict query

Request body

{
  "from": "products",
  "where": {
    "name": "Atria bratwurst 175g"
  },
  "get": "tags.$feature",
  "orderBy": "$p",
  "limit": 5
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_query \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "products",
    "where": { "name": "Atria bratwurst 175g" },
    "get": "tags.$feature",
    "orderBy": "$p",
    "limit": 5
  }'

Response

{
  "offset": 0,
  "total": 25,
  "hits": [
    {
      "$p": 0.30473884347328356,
      "field": "tags",
      "feature": "meat"
    },
    {
      "$p": 0.2715004188138674,
      "field": "tags",
      "feature": "sausage"
    },
    {
      "$p": 0.05475553563545456,
      "field": "tags",
      "feature": "food"
    },
    {
      "$p": 0.03369571423720281,
      "field": "tags",
      "feature": "protein"
    },
    {
      "$p": 0.031178962371886616,
      "field": "tags",
      "feature": "pirkka"
    }
  ]
}

Recommend products which a customer would most likely purchase

Request body

{
  "from": "impressions",
  "where": {
    "context.user": "veronica"
  },
  "get": "product",
  "orderBy": {
    "$p": {
      "$context": {
        "purchase": true
      }
    }
  },
  "limit": 5
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_query \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "impressions",
    "where": { "context.user": "veronica" },
    "get": "product",
    "orderBy": {
      "$p": {
        "$context": { "purchase": true }
      }
    },
    "limit": 5
  }'

Response

{
  "offset": 0,
  "total": 42,
  "hits": [
    {
      "$p": 0.5750580301278168,
      "category": "100",
      "cost": 0.774,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "6410405093677",
      "name": "Pirkka iceberg salad Finland 100g 1st class",
      "price": 1.29,
      "tags": [
        "fresh",
        "vegetable",
        "pirkka",
        "salad"
      ]
    },
    {
      "$p": 0.531656910457125,
      "category": "100",
      "cost": 0.586,
      "googleClicks": 11,
      "googleImpressions": 100,
      "id": "2000604700007",
      "name": "Cucumber Finland",
      "price": 0.9765,
      "tags": [
        "fresh",
        "vegetable"
      ]
    },
    {
      "$p": 0.4817731584887589,
      "category": "100",
      "cost": 0.1,
      "googleClicks": 12,
      "googleImpressions": 100,
      "id": "2000818700008",
      "name": "Pirkka banana",
      "price": 0.166,
      "tags": [
        "fresh",
        "fruit",
        "pirkka"
      ]
    },
    {
      "$p": 0.4297210192015707,
      "category": "100",
      "cost": 0.168,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "2000503600002",
      "name": "Chiquita banana",
      "price": 0.28054,
      "tags": [
        "fresh",
        "fruit"
      ]
    },
    {
      "$p": 0.3893056368583821,
      "category": "111",
      "cost": 1.61,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6414880021620",
      "name": "Ilta Sanomat weekend news",
      "price": 2.3,
      "tags": [
        "news"
      ]
    }
  ]
}

Query with custom scoring

Request body

{
  "from": "impressions",
  "where": {
    "context.user": "veronica"
  },
  "get": "product",
  "orderBy": {
    "$multiply": [
      {
        "$p": {
          "$context": {
            "purchase": true
          }
        }
      },
      "price"
    ]
  },
  "limit": 3
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_query \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "impressions",
    "where": { "context.user": "veronica" },
    "get": "product",
    "orderBy": {
      "$multiply": [
        {
          "$p": {
            "$context": { "purchase": true }
          }
        },
        "price"
      ]
    },
    "limit": 3
  }'

Response

{
  "offset": 0,
  "total": 42,
  "hits": [
    {
      "$score": 1.0368260564060474,
      "category": "111",
      "cost": 2.345,
      "googleClicks": 11,
      "googleImpressions": 100,
      "id": "6413200330206",
      "name": "Lotus Soft Embo 8 rll toilet paper",
      "price": 3.35,
      "tags": [
        "toilet-paper"
      ]
    },
    {
      "$score": 0.8954029647742787,
      "category": "111",
      "cost": 1.61,
      "googleClicks": 10,
      "googleImpressions": 100,
      "id": "6414880021620",
      "name": "Ilta Sanomat weekend news",
      "price": 2.3,
      "tags": [
        "news"
      ]
    },
    {
      "$score": 0.7418248588648836,
      "category": "100",
      "cost": 0.774,
      "googleClicks": 9,
      "googleImpressions": 100,
      "id": "6410405093677",
      "name": "Pirkka iceberg salad Finland 100g 1st class",
      "price": 1.29,
      "tags": [
        "fresh",
        "vegetable",
        "pirkka",
        "salad"
      ]
    }
  ]
}

Batch

POST/api/v1/_batch

Predict category and tags, and also fetch similar products for reference

Request body

[
  {
    "from": "products",
    "where": {
      "name": "rye bread"
    },
    "predict": "category"
  },
  {
    "from": "products",
    "where": {
      "name": "rye bread"
    },
    "predict": "tags",
    "exclusiveness": false
  },
  {
    "from": "products",
    "similarity": {
      "name": "rye bread"
    }
  }
]

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_batch \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  [
    {
      "from": "products",
      "where": { "name": "rye bread" },
      "predict": "category"
    },
    {
      "from": "products",
      "where": { "name": "rye bread" },
      "predict": "tags",
      "exclusiveness": false
    },
    {
      "from": "products",
      "similarity": { "name": "rye bread" }
    }
  ]'

Response

[
  {
    "offset": 0,
    "total": 11,
    "hits": [
      {
        "$p": 0.8272154843087481,
        "field": "category",
        "feature": "101"
      },
      {
        "$p": 0.021987233173235084,
        "field": "category",
        "feature": "100"
      },
      {
        "$p": 0.021987233173235084,
        "field": "category",
        "feature": "102"
      },
      {
        "$p": 0.021987233173235084,
        "field": "category",
        "feature": "103"
      },
      {
        "$p": 0.021987233173235084,
        "field": "category",
        "feature": "104"
      },
      {
        "$p": 0.021987233173235084,
        "field": "category",
        "feature": "108"
      },
      {
        "$p": 0.018399942828573393,
        "field": "category",
        "feature": "109"
      },
      {
        "$p": 0.014779115894842236,
        "field": "category",
        "feature": "111"
      },
      {
        "$p": 0.014779115894842236,
        "field": "category",
        "feature": "115"
      },
      {
        "$p": 0.007445087603409161,
        "field": "category",
        "feature": "106"
      }
    ]
  },
  {
    "offset": 0,
    "total": 25,
    "hits": [
      {
        "$p": 0.8392856253737974,
        "field": "tags",
        "feature": "gluten"
      },
      {
        "$p": 0.8376068362594504,
        "field": "tags",
        "feature": "bread"
      },
      {
        "$p": 0.12633864926055016,
        "field": "tags",
        "feature": "pirkka"
      },
      {
        "$p": 0.11962185955575856,
        "field": "tags",
        "feature": "food"
      },
      {
        "$p": 0.11151547978856242,
        "field": "tags",
        "feature": "meat"
      },
      {
        "$p": 0.09564066656611062,
        "field": "tags",
        "feature": "protein"
      },
      {
        "$p": 0.08898199227460421,
        "field": "tags",
        "feature": "drink"
      },
      {
        "$p": 0.08898199227460421,
        "field": "tags",
        "feature": "lactose"
      },
      {
        "$p": 0.08141226436859195,
        "field": "tags",
        "feature": "fresh"
      },
      {
        "$p": 0.07273797470048293,
        "field": "tags",
        "feature": "candy"
      }
    ]
  },
  {
    "offset": 0,
    "total": 42,
    "hits": [
      {
        "$score": 2.967681932293201,
        "category": "101",
        "cost": 1.183,
        "googleClicks": 12,
        "googleImpressions": 100,
        "id": "6437002001454",
        "name": "VAASAN Ruispalat 660g 12 pcs fullcorn rye bread",
        "price": 1.69,
        "tags": [
          "gluten",
          "bread"
        ]
      },
      {
        "$score": 2.967681932293201,
        "category": "101",
        "cost": 1.295,
        "googleClicks": 11,
        "googleImpressions": 100,
        "id": "6411402202208",
        "name": "Fazer Puikula fullcorn rye bread 9 pcs/500g",
        "price": 1.85,
        "tags": [
          "gluten",
          "bread"
        ]
      },
      {
        "$score": 2.967681932293201,
        "category": "101",
        "cost": 0.945,
        "googleClicks": 10,
        "googleImpressions": 100,
        "id": "6408180733260",
        "name": "Vaasan Ruispalat thin sliced rye bread 6pcs/195g",
        "price": 1.35,
        "tags": [
          "gluten",
          "bread"
        ]
      },
      {
        "$score": 2.967681932293201,
        "category": "101",
        "cost": 0.903,
        "googleClicks": 9,
        "googleImpressions": 100,
        "id": "6413467282508",
        "name": "Fazer Puikula fullcorn rye bread 330g",
        "price": 1.29,
        "tags": [
          "gluten",
          "bread"
        ]
      },
      {
        "$score": 2.967681932293201,
        "category": "101",
        "cost": 0.693,
        "googleClicks": 8,
        "googleImpressions": 100,
        "id": "6413466080204",
        "name": "Oululainen reissumies dark rye bread 4pcs/280g",
        "price": 0.99,
        "tags": [
          "gluten",
          "bread"
        ]
      },
      {
        "$score": 1.6441207746609814,
        "category": "102",
        "cost": 0.623,
        "googleClicks": 9,
        "googleImpressions": 100,
        "id": "6407870070333",
        "name": "Atria lauantaimakkara bread sausage 225g",
        "price": 0.89,
        "tags": [
          "meat",
          "sausage",
          "with-bread"
        ]
      },
      {
        "$score": 1.6441207746609814,
        "category": "103",
        "cost": 1.043,
        "googleClicks": 8,
        "googleImpressions": 100,
        "id": "6409100024628",
        "name": "Breadded chicke nuggets 200g",
        "price": 1.49,
        "tags": [
          "meat",
          "food",
          "protein"
        ]
      },
      {
        "$score": 1,
        "category": "100",
        "cost": 0.1,
        "googleClicks": 12,
        "googleImpressions": 100,
        "id": "2000818700008",
        "name": "Pirkka banana",
        "price": 0.166,
        "tags": [
          "fresh",
          "fruit",
          "pirkka"
        ]
      },
      {
        "$score": 1,
        "category": "100",
        "cost": 0.586,
        "googleClicks": 11,
        "googleImpressions": 100,
        "id": "2000604700007",
        "name": "Cucumber Finland",
        "price": 0.9765,
        "tags": [
          "fresh",
          "vegetable"
        ]
      },
      {
        "$score": 1,
        "category": "100",
        "cost": 0.774,
        "googleClicks": 10,
        "googleImpressions": 100,
        "id": "6410405060457",
        "name": "Pirkka bio cherry tomatoes 250g international 1lk",
        "price": 1.29,
        "tags": [
          "fresh",
          "vegetable",
          "pirkka",
          "tomato"
        ]
      }
    ]
  }
]

Aggregate

POST/api/v1/_aggregate

Count amount of purchases and CTR of a product

Request body

{
  "from": "impressions",
  "where": {
    "product.id": "6408180733260"
  },
  "aggregate": [
    "purchase.$sum",
    "purchase.$mean"
  ]
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_aggregate \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "impressions",
    "where": { "product.id": "6408180733260" },
    "aggregate": ["purchase.$sum", "purchase.$mean"]
  }'

Response

{
  "mean": 0.046141607000795545,
  "mean.samples": 2514,
  "mean.variance": 0.04401255910417968,
  "mean.standardDeviation": 0.20979170408807798,
  "mean.standardError": 0.004184134860196707,
  "sum": 116,
  "sum.samples": 2514
}

Count more statistics for product 6408180733260 with custom names

Request body

{
  "from": "impressions",
  "where": {
    "product.id": "6408180733260"
  },
  "aggregate": {
    "impressions": "$f",
    "purchases": "purchase.$sum",
    "conversion": "purchase.$mean",
    "searches": {
      "$f": {
        "context.type": "search"
      }
    },
    "prefills": {
      "$f": {
        "context.type": "prefill"
      }
    },
    "recommendations": {
      "$f": {
        "context.type": "recommendation"
      }
    }
  }
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/_aggregate \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "from": "impressions",
    "where": { "product.id": "6408180733260" },
    "aggregate": {
      "impressions": "$f",
      "purchases": "purchase.$sum",
      "conversion": "purchase.$mean",
      "searches": {
        "$f": { "context.type": "search" }
      },
      "prefills": {
        "$f": { "context.type": "prefill" }
      },
      "recommendations": {
        "$f": { "context.type": "recommendation" }
      }
    }
  }'

Response

{
  "recommendations": 0,
  "prefills": 69,
  "searches": 2292,
  "conversion": 0.046141607000795545,
  "conversion.samples": 2514,
  "conversion.variance": 0.04401255910417968,
  "conversion.standardDeviation": 0.20979170408807798,
  "conversion.standardError": 0.004184134860196707,
  "purchases": 116,
  "purchases.samples": 2514,
  "impressions": 2514
}

Create jobs

POST/api/v1/jobs/{query}

Example request

Request body

{
  "test": {
    "$index": {
      "$mod": [
        4,
        0
      ]
    }
  },
  "evaluate": {
    "from": "products",
    "where": {
      "name": {
        "$match": {
          "$get": "name"
        }
      }
    },
    "predict": "category"
  }
}

Request

curl -X POST \
  http://localhost:4170/db/aito-demo/api/v1/jobs/_evaluate \
  -H 'content-type: application/json' \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi' \
  -d '
  {
    "test": {
      "$index": {
        "$mod": [4, 0]
      }
    },
    "evaluate": {
      "from": "products",
      "where": {
        "name": {
          "$match": { "$get": "name" }
        }
      },
      "predict": "category"
    }
  }'

Response

{
  "id": "75fb9b30-20e0-4dcd-9dde-16c9f08809bb",
  "parameters": {},
  "path": "_evaluate",
  "startedAt": "2025-12-23T13:37:28.954119Z"
}

Get status of all jobs

GET/api/v1/jobs/

Example request

Request

curl -X GET \
  http://localhost:4170/db/aito-demo/api/v1/jobs/ \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi'

Response

[
  {
    "id": "75fb9b30-20e0-4dcd-9dde-16c9f08809bb",
    "parameters": {},
    "path": "_evaluate",
    "startedAt": "2025-12-23T13:37:28.954119Z"
  }
]

Get status of a job

GET/api/v1/jobs/{uuid}

Example request

Request

curl -X GET \
  http://localhost:4170/db/aito-demo/api/v1/jobs/75fb9b30-20e0-4dcd-9dde-16c9f08809bb \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi'

Response

{
  "id": "75fb9b30-20e0-4dcd-9dde-16c9f08809bb",
  "parameters": {},
  "path": "_evaluate",
  "startedAt": "2025-12-23T13:37:28.954119Z"
}

Get result of a job

GET/api/v1/jobs/{uuid}/result

Example request

Request

curl -X GET \
  http://localhost:4170/db/aito-demo/api/v1/jobs/75fb9b30-20e0-4dcd-9dde-16c9f08809bb/result \
  -H 'x-api-key: yg4rTlXkqDzm4y8gPeY75HCKaNwfbTQ2si64ONTi'

Get database schema

GET/api/v1/schema

Create database schema

PUT/api/v1/schema

Delete database

DELETE/api/v1/schema

Get table schema

GET/api/v1/schema/{table}

Create table schema

PUT/api/v1/schema/{table}

Delete table

DELETE/api/v1/schema/{table}

Get column schema

GET/api/v1/schema/{table}/{column}

Add or replace column

PUT/api/v1/schema/{table}/{column}

Delete column

DELETE/api/v1/schema/{table}/{column}

Rename a table

POST/api/v1/schema/_rename

Copy a table

POST/api/v1/schema/_copy

Insert entry

POST/api/v1/data/{table}

Insert multiple entries

POST/api/v1/data/{table}/batch

Modify data

POST/api/v1/data/_modify

Delete entries

POST/api/v1/data/_delete

Initiate file upload

POST/api/v1/data/{table}/file

Trigger file processing

POST/api/v1/data/{table}/file/{uuid}

Get file processing status

GET/api/v1/data/{table}/file/{uuid}

Optimize the database

POST/api/v1/data/{table}/optimize

UserDefinedTableSchema

UserDefinedTableSchema

Format

{
  "type": string,
  "columns": object
}

Referenced in

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"
    }
  }
}

Example

{
  "name": "My product",
  "price": 172.19
}

ColumnType

BooleanType

Format

{
  "type": string,
  "nullable": boolean,
  "link": string
}

Referenced in

Example

{
  "type": "boolean"
}

DecimalType

Format

{
  "type": string,
  "nullable": boolean,
  "link": string
}

Referenced in

Example

{
  "type": "Decimal",
  "nullable": false
}

IntType

Format

{
  "type": string,
  "nullable": boolean,
  "link": string
}

Referenced in

Example

{
  "type": "Int"
}

StringType

Format

{
  "type": string,
  "nullable": boolean,
  "link": string
}

Referenced in

Example

{
  "type": "String",
  "nullable": false
}

TextType

Format

{
  "type": string,
  "analyzer": Analyzer,
  "nullable": boolean,
  "link": string
}

Referenced in

Example

{
  "type": "Text",
  "analyzer": "English",
  "nullable": false
}

JsonType

Format

{
  "type": string,
  "nullable": boolean,
  "link": string
}

Referenced in

Example

{
  "type": "Json",
  "nullable": false
}

ArrayType

Format

{
  "type": string,
  "nullable": boolean
}

Referenced in

Example

{
  "type": "Int[]",
  "nullable": false
}

Analyzer

AliasAnalyzer

Referenced in

CharNGramAnalyzer

Format

{
  "type": string,
  "minGram": integer,
  "maxGram": integer
}

Referenced in

Example

{
  "type": "char-ngram",
  "minGram": 2,
  "maxGram": 3
}

DelimiterAnalyzer

Format

{
  "type": string,
  "delimiter": string,
  "trimWhitespace": boolean
}

Referenced in

LanguageAnalyzer

Format

{
  "type": string,
  "language": string,
  "useDefaultStopWords": boolean,
  "customStopWords": [string],
  "customKeyWords": [string]
}

Referenced in

TokenNGramAnalyzer

Format

{
  "type": string,
  "source": Analyzer,
  "minGram": integer,
  "maxGram": integer,
  "tokenSeparator": string
}

Referenced in

Text operators

$match

Format

{
  "$match": $toString or GetValueExpression or string
}

Referenced in

Example

{
  "$match": "coffee"
}

More examples

{
  "from": "products",
  "where": {
    "name": {
      "$match": "coffee"
    }
  }
}

$startsWith

Format

{
  "$startsWith": $toString or GetValueExpression or string
}

Referenced in

Example

{
  "$startsWith": "Cucumber"
}

More examples

{
  "from": "products",
  "where": {
    "name": {
      "$startsWith": "Cucumber"
    }
  }
}

Comparison operators

$gt

Format

{
  "$gt": GetValueExpression or integer or integer or number or null or ArrayValue or $toString or boolean or string or Json
}

Referenced in

Example

{
  "$gt": 8
}

More examples

{
  "$gt": 231.1
}
{
  "$gt": "20150308"
}
{
  "from": "products",
  "where": {
    "price": {
      "$gt": 2.14
    }
  }
}

$gte

Format

{
  "$gte": GetValueExpression or integer or integer or number or null or ArrayValue or $toString or boolean or string or Json
}

Referenced in

Example

{
  "$gte": -2
}

More examples

{
  "$gte": 0
}
{
  "$gte": "20180502"
}
{
  "from": "products",
  "where": {
    "price": {
      "$gte": 2
    }
  }
}

$lt

Format

{
  "$lt": GetValueExpression or integer or integer or number or null or ArrayValue or $toString or boolean or string or Json
}

Referenced in

Example

{
  "$lt": 4
}

More examples

{
  "$lt": -12.1
}
{
  "$lt": "20180502"
}
{
  "from": "products",
  "where": {
    "price": {
      "$lt": 1.24
    }
  }
}

$lte

Format

{
  "$lte": GetValueExpression or integer or integer or number or null or ArrayValue or $toString or boolean or string or Json
}

Referenced in

Example

{
  "$lte": 8
}

More examples

{
  "$lte": 0
}
{
  "$lte": "20180502"
}
{
  "from": "products",
  "where": {
    "price": {
      "$lte": 1
    }
  }
}

$has

Format

{
  "$has": GetValueExpression or integer or integer or number or null or ArrayValue or $toString or boolean or string or Json
}

Referenced in

Example

{
  "$has": "drink"
}

More examples

{
  "from": "products",
  "where": {
    "tags": {
      "$has": "drink"
    }
  }
}

$defined

Format

{
  "$defined": boolean
}

Referenced in

Example

{
  "$defined": true
}

$exists

Format

{
  "$exists": PropositionSet
}

Referenced in

Example

{
  "$exists": [
    "query",
    "product.tags"
  ]
}

More examples

{
  "from": "impressions",
  "where": {
    "$on": [
      {
        "$exists": [
          "query",
          "customer.tags"
        ]
      },
      {
        "click": true
      }
    ]
  },
  "relate": [
    "product.title",
    "product.tags"
  ]
}

Logical operators

$and

Format

{
  "$and": [Proposition or PrimitiveProposition]
}

Referenced in

Example

{
  "$and": [
    {
      "$gt": 10
    },
    {
      "$lt": 20
    }
  ]
}

More examples

{
  "from": "products",
  "where": {
    "price": {
      "$and": [
        {
          "$gt": 1.5
        },
        {
          "$lt": 2.1
        }
      ]
    }
  }
}

$or

Format

{
  "$or": [Proposition or PrimitiveProposition]
}

Referenced in

Example

{
  "$or": [
    {
      "tags": "cover"
    },
    {
      "tags": "laptop"
    }
  ]
}

More examples

{
  "from": "products",
  "where": {
    "price": {
      "$or": [
        {
          "$lt": 0.9
        },
        {
          "$gt": 2.1
        }
      ]
    }
  }
}

$not

Format

{
  "$not": Proposition or PrimitiveProposition
}

Referenced in

Example

{
  "$not": {
    "tags": "laptop"
  }
}

More examples

{
  "$not": {
    "$lt": 0
  }
}
{
  "from": "products",
  "where": {
    "price": {
      "$not": {
        "$lt": 1.1
      }
    }
  }
}

Sort operators

$asc

Format

{
  "$asc": Value
}

Referenced in

Example

{
  "$asc": "price"
}

More examples

{
  "$asc": "product.price"
}
{
  "$asc": {
    "$multiply": [
      "product.price",
      "$p"
    ]
  }
}

$asc(Relate)

Format

{
  "$asc": string
}

Referenced in

Example

{
  "$asc": "lift"
}

$desc

Format

{
  "$desc": Value
}

Referenced in

Example

{
  "$desc": "price"
}

More examples

{
  "$desc": "product.price"
}
{
  "$desc": {
    "$multiply": [
      "product.price",
      "$p"
    ]
  }
}

$desc(Relate)

Format

{
  "$desc": string
}

Referenced in

Example

{
  "$desc": "info.miTrue"
}

Arithmetic operators

$mod

Referenced in

Example

{
  "$mod": [
    2,
    0
  ]
}

More examples

{
  "$mod": {
    "divisor": 2,
    "remainder": 0
  }
}
{
  "from": "products",
  "where": {
    "price": {
      "$mod": {
        "divisor": 2,
        "remainder": 0
      }
    }
  }
}

$multiply

Format

{
  "$multiply": [Score]
}

Referenced in

Example

{
  "$multiply": [
    "price",
    2
  ]
}

$divide

Format

{
  "$divide": object or [Score]
}

Referenced in

Example

{
  "$divide": [
    "cost",
    4
  ]
}

Example

{
  "$pow": [
    "width",
    2
  ]
}

$sum

Format

{
  "$sum": ContextValueQuery or [Score]
}

Referenced in

Example

{
  "$sum": [
    "priceNet",
    "priceVat"
  ]
}

$subtract

Format

{
  "$subtract": object or [Score]
}

Referenced in

Example

{
  "$subtract": [
    "price",
    2
  ]
}

Advanced operators

$atomic

Format

{
  "$atomic": Proposition
}

Referenced in

Example

{
  "$atomic": {
    "tags": "pen",
    "price": {
      "$gte": 200
    }
  }
}

More examples

{
  "from": "products",
  "where": {
    "$atomic": {
      "tags": "pen",
      "price": {
        "$gte": 200
      }
    }
  }
}

$context

Format

{
  "$context": Proposition
}

Referenced in

Example

{
  "$context": {
    "click": true
  }
}

More examples

{
  "from": "impressions",
  "where": {
    "customerEmail": "john.doe@aito.ai",
    "query": "laptop"
  },
  "get": "product",
  "orderBy": {
    "$p": {
      "$context": {
        "click": true
      }
    }
  }
}

$hit

Format

{
  "$hit": Score
}

Referenced in

Example

{
  "$hit": "price"
}

More examples

{
  "$hit": "$similarity"
}
{
  "from": "impressions",
  "where": {
    "product.title": {
      "$match": "iphone"
    }
  },
  "get": "product",
  "orderBy": {
    "$multiply": [
      {
        "$hit": "$similarity"
      },
      {
        "$hit": "price"
      }
    ]
  }
}

$on

Referenced in

Example

{
  "$on": {
    "prop": {
      "click": true
    },
    "on": {
      "user.tags": "nyc"
    }
  }
}

More examples

{
  "$on": [
    {
      "click": true
    },
    {
      "user.tags": "nyc"
    }
  ]
}

$knn

Referenced in

Example

{
  "$knn": [
    4,
    {
      "tags": "laptop"
    }
  ]
}

More examples

{
  "$knn": {
    "k": 4,
    "near": {
      "tags": "laptop"
    }
  }
}

$nn

Referenced in

Example

{
  "$nn": [
    {
      "tags": "laptop"
    }
  ]
}

More examples

{
  "$nn": {
    "near": {
      "tags": "laptop"
    }
  }
}

$numeric

Format

{
  "$numeric": GetValueExpression or integer or integer or number or null
}

Referenced in

Example

{
  "$numeric": 42
}

More examples

{
  "$numeric": 3.14
}

$hash

Format

{
  "$hash": Proposition or PrimitiveProposition
}

Referenced in

Example

{
  "$hash": {
    "$mod": [
      2,
      1
    ]
  }
}

$toString

Format

{
  "$toString": GetValueExpression or integer or integer or number or null or ArrayValue or $toString or boolean or string or Json
}

Example

{
  "$toString": 4
}

Scoring operators

$p

Referenced in

Example

"$p"

More examples

{
  "from": "messages",
  "get": "user",
  "orderBy": "$p",
  "where": {
    "message": {
      "$match": "dog"
    }
  }
}

$f

Referenced in

Example

"$f"

More examples

{
  "from": "impressions",
  "get": "product",
  "orderBy": "$f"
}

$lift

Referenced in

Example

"$lift"

More examples

{
  "from": "messages",
  "get": "user",
  "orderBy": "$lift",
  "where": {
    "message": {
      "$match": "dog"
    }
  }
}

$similarity

Referenced in

Example

"$similarity"

More examples

{
  "from": "product",
  "get": "message",
  "orderBy": "$similarity",
  "where": {
    "title": {
      "$match": "iphone"
    }
  }
}

$sameness

Referenced in

Example

"$sameness"

More examples

{
  "from": "product",
  "orderBy": "$sameness",
  "where": {
    "title": {
      "$match": "iphone"
    }
  }
}

$hit

Format

{
  "$hit": Score
}

Referenced in

Example

{
  "$hit": "price"
}

More examples

{
  "$hit": "$similarity"
}
{
  "from": "impressions",
  "where": {
    "product.title": {
      "$match": "iphone"
    }
  },
  "get": "product",
  "orderBy": {
    "$multiply": [
      {
        "$hit": "$similarity"
      },
      {
        "$hit": "price"
      }
    ]
  }
}

$p object

Format

{
  "$p": PropositionSet
}

Referenced in

Example

{
  "$p": "tags"
}

More examples

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

$probability

Format

{
  "$probability": object
}

Referenced in

Example

{
  "$probability": {
    "of": "tags"
  }
}

More examples

{
  "$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"
    }
  }
}

$lift object

Format

{
  "$lift": PropositionSet
}

Referenced in

Example

{
  "$lift": "tags"
}

More examples

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

$probabilityLift

Format

{
  "$probabilityLift": object
}

Referenced in

Example

{
  "$probabilityLift": {
    "of": "tags"
  }
}

More examples

{
  "$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"
    }
  }
}

$mean

Format

{
  "$mean": ContextValueQuery
}

Referenced in

Example

{
  "$mean": {
    "$context": "score"
  }
}

$freqP

Format

{
  "$freqP": object
}

Referenced in

Example

{
  "$freqP": {
    "f": "clickCount",
    "n": "impressionCount",
    "p": 0.5
  }
}

$decision

Format

{
  "$decision": object
}

Referenced in

Example

{
  "$decision": {
    "score": {
      "$mean": {
        "$context": "clickThroughRate"
      }
    },
    "seed": 0
  }
}

$similarity object

Format

{
  "$similarity": Proposition or PrimitiveProposition
}

Referenced in

Example

{
  "$similarity": {
    "title": "apple iphone",
    "tags": "premium ios phone"
  }
}

More examples

{
  "from": "products",
  "orderBy": {
    "$similarity": {
      "title": "apple iphone",
      "tags": "premium ios phone"
    }
  }
}

$sameness object

Format

{
  "$sameness": Proposition or PrimitiveProposition
}

Referenced in

Example

{
  "$sameness": {
    "title": "apple iphone",
    "tags": "premium ios phone"
  }
}

More examples

{
  "from": "products",
  "orderBy": {
    "$sameness": {
      "title": "apple iphone",
      "tags": "premium ios phone"
    }
  }
}

$analogy object

Format

{
  "$analogy": object
}

Referenced in

Example

{
  "$analogy": {
    "with": "veronica",
    "basedOn": "purchases"
  }
}

More examples

{
  "from": "products",
  "get": "title",
  "orderBy": {
    "$analogy": {
      "with": "ideapad",
      "basedOn": "tags"
    }
  }
}

$normalize

Format

{
  "$normalize": Score
}

Referenced in

Example

{
  "$normalize": "$lift"
}

More examples

{
  "$normalize": {
    "$lift": "name"
  }
}

$impact

Format

{
  "$impact": object
}

Referenced in

Example

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

More examples

{
  "from": "projects",
  "get": "customer.industry",
  "orderBy": {
    "$impact": {
      "value": {
        "$context": "profit"
      }
    }
  }
}

$f (context)

Format

{
  "$f": ContextPropositionQuery
}

Referenced in

Example

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

More examples

{
  "from": "impressions",
  "get": "product",
  "orderBy": {
    "$f": {
      "$context": {
        "$click": true
      }
    }
  }
}

Aggregate operators

$mean

Format

{
  "$mean": Score
}

Referenced in

Example

{
  "$mean": "ctr"
}

More examples

{
  "$mean": {
    "$freqP": {
      "f": "clicks",
      "n": "impressions"
    }
  }
}

$sum

Format

{
  "$sum": Score
}

Referenced in

Example

{
  "$sum": "visits"
}

More examples

{
  "$sum": "purchase"
}

$f (aggregate)

Format

{
  "$f": Proposition
}

Referenced in

Example

{
  "$f": {
    "click": false
  }
}

More examples

{
  "$f": {
    "price": {
      "$gt": 100
    }
  }
}

NamedAggregateProjection

Referenced in

Example

{
  "aggregate": {
    "clicks": {
      "$f": {
        "click": true
      }
    },
    "ctr": {
      "$mean": "click"
    },
    "impressions": "$f"
  },
  "from": "impressions",
  "where": {
    "product.name": "MyProduct"
  }
}

More examples

{
  "failureCount": {
    "$f": {
      "success": false
    }
  }
}

Projection operators

$index (projection)

Referenced in

Example

"$index"

$why (object)

Format

{
  "$why": object
}

Referenced in

Example

{
  "$why": {
    "highlight": {
      "posPreTag": "<b>",
      "posPostTag": "</b>",
      "negPreTag": "<em>",
      "negPostTag": "</em>",
      "encoder": "html",
      "posThreshold": 1.1,
      "negThreshold": 0.9
    },
    "matches": {}
  }
}

$highlight

Referenced in

Example

"$highlight"

$highlight (object)

Format

{
  "$highlight": object
}

Referenced in

Example

{
  "$highlight": {
    "posPreTag": "<b>",
    "posPostTag": "</b>",
    "negPreTag": "<em>",
    "negPostTag": "</em>",
    "encoder": "html"
  }
}

$matches

Referenced in

Example

"$matches"

$matches (object)

Format

{
  "$matches": object
}

Referenced in

Example

{
  "$matches": {}
}

NamedProjection

Referenced in

Example

{
  "from": "impressions",
  "get": "product",
  "select": {
    "clicks": {
      "$f": {
        "$context": {
          "click": true
        }
      }
    },
    "ctr": {
      "$mean": {
        "$context": "click"
      }
    },
    "impressions": "$f",
    "product": "name"
  }
}

More examples

{
  "failures": {
    "$f": {
      "$context": {
        "success": false
      }
    }
  }
}
{
  "id": "id",
  "mean": {
    "$mean": {
      "$context": "product.price"
    }
  }
}
{
  "$value": "$value",
  "field": "field",
  "id": "id"
}

Built-in attributes

$index

Referenced in

Example

"$index"

$sort

Referenced in

Example

"$sort"

$score

Referenced in

Example

"$score"

$p

Referenced in

Example

"$p"

$why

Referenced in

Example

"$why"

$value

Referenced in

Example

"$value"

$proposition

Referenced in

Example

"$proposition"

Explanation objects

SumExplanation

Format

{
  "type": string,
  "terms": [ScoreExplanation]
}

Referenced in

Example

{
  "terms": [
    {
      "field": "id",
      "type": "field",
      "value": 4
    },
    {
      "field": "price",
      "type": "field",
      "value": 1500
    }
  ],
  "type": "sum"
}

SubtractionExplanation

Format

{
  "type": string,
  "minuend": ScoreExplanation,
  "subtrahend": ScoreExplanation
}

Referenced in

Example

{
  "minuend": {
    "field": "price",
    "type": "field",
    "value": 119.5
  },
  "subtrahend": {
    "field": "cost",
    "type": "field",
    "value": 100.5
  },
  "type": "subtraction"
}

ProductExplanation

Format

{
  "type": string,
  "factors": [ScoreExplanation]
}

Referenced in

Example

{
  "factors": [
    {
      "factors": [
        {
          "type": "baseLift",
          "value": 31
        }
      ],
      "proposition": {
        "id": 3
      },
      "type": "hitPropositionLift",
      "value": 31
    },
    {
      "field": "price",
      "type": "field",
      "value": 1500
    }
  ],
  "type": "product"
}

BaseLiftExplanation

Format

{
  "type": string,
  "value": number
}

Referenced in

Example

{
  "type": "baseLift",
  "value": 31
}

DivisionExplanation

Format

{
  "type": string,
  "dividend": ScoreExplanation,
  "divisor": ScoreExplanation
}

Referenced in

Example

{
  "dividend": {
    "field": "return",
    "type": "field",
    "value": 400000
  },
  "divisor": {
    "field": "investment",
    "type": "field",
    "value": 250000
  },
  "type": "division"
}

BaseProbabilityExplanation

Format

{
  "type": string,
  "value": number,
  "proposition": PropositionExplanation
}

Referenced in

Example

{
  "proposition": {
    "click": true
  },
  "type": "baseP",
  "value": 0.5
}

Format

{
  "type": string,
  "proposition": PropositionExplanation,
  "value": number
}

Referenced in

Format

{
  "type": string,
  "proposition": PropositionExplanation,
  "value": number
}

Referenced in

Example

{
  "proposition": {
    "product": 5
  },
  "type": "hitLinkPropositionLift",
  "value": 2.32
}

DecoratedScoreExplanation

Referenced in

HitPropositionLiftExplanation

Format

{
  "type": string,
  "proposition": PropositionExplanation,
  "value": number,
  "factors": [ScoreExplanation]
}

Referenced in

Example

{
  "factors": [
    {
      "type": "baseLift",
      "value": 31
    }
  ],
  "proposition": {
    "field": 4
  },
  "type": "hitPropositionLift",
  "value": 31
}

ConstantExplanation

Format

{
  "type": string,
  "value": number
}

Referenced in

DefaultValueExplanation

Format

{
  "type": string,
  "value": number
}

Referenced in

Example

{
  "type": "default",
  "value": 1
}

NamedExplanation

Format

{
  "type": string,
  "name": string,
  "value": number
}

Referenced in

Example

{
  "name": "exclusiveness",
  "type": "normalizer",
  "value": 0.2982788431762749
}

PredictExplanation

Format

{
  "type": string,
  "factors": [ScoreExplanation]
}

Referenced in

Example

{
  "factors": [
    {
      "type": "baseP",
      "value": 0.8048780487804879
    },
    {
      "name": "exclusiveness",
      "type": "normalizer",
      "value": 0.04604801347746731
    }
  ],
  "type": "product"
}

ExponentExplanation

Format

{
  "type": string,
  "value": number,
  "base": ScoreExplanation,
  "power": ScoreExplanation
}

Referenced in

Example

{
  "base": {
    "type": "idf",
    "value": 1.7551720221592049
  },
  "power": {
    "type": "tf",
    "value": 1
  },
  "type": "exponent",
  "value": 1.7551720221592049
}

TermFrequencyExplanation

Format

{
  "type": string,
  "value": number
}

Referenced in

Example

{
  "type": "tf",
  "value": 1
}

InverseDocumentFrequencyExplanation

Format

{
  "type": string,
  "value": number
}

Referenced in

Example

{
  "type": "idf",
  "value": 1.7551720221592049
}

FieldExplanation

Format

{
  "type": string,
  "field": string,
  "value": number
}

Referenced in

Example

{
  "field": "price",
  "type": "field",
  "value": 1500
}

Explanation proposition objects

FieldPropositionExplanation

Format

{
  "fieldName": PropositionExplanation
}

HasExplanation

Format

{
  "$has": IntArray or LongArray or DecimalArray or StringArray or BooleanArray or object or object or object or object or object or integer or integer or number or boolean or null or string or object
}

AndExplanation

Format

{
  "$and": [PropositionExplanation]
}

OrExplanation

Format

{
  "$or": [PropositionExplanation]
}

OnExplanation

Format

{
  "$on": [PropositionExplanation]
}

NotExplanation

Format

{
  "$not": PropositionExplanation
}

StartsWithExplanation

Format

{
  "$startsWith": string
}

GtExplanation

Format

{
  "$gt": IntArray or LongArray or DecimalArray or StringArray or BooleanArray or object or object or object or object or object or integer or integer or number or boolean or null or string or object
}

GteExplanation

Format

{
  "$gte": IntArray or LongArray or DecimalArray or StringArray or BooleanArray or object or object or object or object or object or integer or integer or number or boolean or null or string or object
}

LtExplanation

Format

{
  "$lt": IntArray or LongArray or DecimalArray or StringArray or BooleanArray or object or object or object or object or object or integer or integer or number or boolean or null or string or object
}

LteExplanation

Format

{
  "$lte": IntArray or LongArray or DecimalArray or StringArray or BooleanArray or object or object or object or object or object or integer or integer or number or boolean or null or string or object
}

DefinedExplanation

Format

{
  "$defined": boolean
}

NumericExplanation

Format

{
  "$numeric": number
}

KnnExplanation

Format

{
  "$knn": object
}

NnExplanation

Format

{
  "$nn": object
}

IsPropositionExplanation

Other types

ColumnName

Referenced in

Example

"id"

More examples

"age"
"product.id"

EvaluateGenericQuery

Format

{
  "from": From,
  "where": Proposition,
  "get": Get,
  "orderBy": OrderBy,
  "select": Projection,
  "offset": integer,
  "limit": integer
}

Referenced in

Example

{
  "from": "impressions",
  "get": "product",
  "limit": 20,
  "offset": 10
}

EvaluateGroupedOperation

Example

{
  "from": "impressions",
  "goal": {
    "purchase": "true"
  },
  "recommend": "product",
  "where": {
    "product.name": {
      "$get": "query"
    },
    "session.user": {
      "$get": "session.user"
    }
  }
}

More examples

{
  "from": "impressions",
  "get": "product",
  "orderBy": {
    "$p": {
      "purchase": true
    }
  },
  "where": {
    "product.name": {
      "$get": "query"
    },
    "session.user": {
      "$get": "session.user"
    }
  }
}

EvaluateGroupedQuery

Format

{
  "train": Proposition,
  "test": Proposition,
  "testSource": TestSource,
  "select": Selection,
  "group": string,
  "goal": Proposition,
  "evaluate": EvaluateGroupedOperation
}

Referenced in

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
    }
  }
}

EvaluateMatch

Format

{
  "from": From,
  "where": Proposition,
  "select": Projection,
  "match": Get,
  "basedOn": PropositionSet,
  "offset": integer,
  "limit": integer
}

Referenced in

Example

{
  "from": "impressions",
  "limit": 2,
  "match": "prevProduct",
  "offset": 2,
  "select": [
    "title",
    "description",
    "price"
  ],
  "where": {
    "customer": 4,
    "query": "laptop"
  }
}

EvaluateMultiGenericQuery

Format

{
  "from": From,
  "where": Proposition,
  "get": Get,
  "orderBy": OrderBy,
  "select": Projection,
  "offset": integer,
  "limit": integer
}

Example

{
  "from": "impressions",
  "get": "product",
  "orderBy": {
    "$p": {
      "purchase": true
    }
  },
  "where": {
    "product.name": {
      "$get": "query"
    },
    "session.user": {
      "$get": "session.user"
    }
  }
}

EvaluateOperation

Referenced in

Example

{
  "from": "messages",
  "get": "product",
  "similarity": {
    "description": {
      "$get": "message"
    },
    "title": {
      "$get": "message"
    }
  }
}

More examples

{
  "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"
    }
  }
}

EvaluatePredict

Format

{
  "from": From,
  "where": Proposition,
  "predict": PropositionSet,
  "basedOn": PropositionSet,
  "exclusiveness": boolean,
  "select": Projection,
  "offset": integer,
  "limit": integer
}

Referenced in

Example

{
  "from": "products",
  "predict": "category",
  "where": {
    "name": {
      "$get": "name"
    }
  }
}

EvaluateQuery

Format

{
  "train": Proposition,
  "test": Proposition,
  "testSource": TestSource,
  "select": Selection,
  "evaluate": EvaluateOperation
}

Referenced in

Example

{
  "evaluate": {
    "from": "products",
    "predict": "category",
    "where": {
      "name": {
        "$get": "name"
      }
    }
  },
  "select": [
    "accuracy",
    "meanRank",
    "n"
  ],
  "test": {
    "$index": {
      "$mod": [
        10,
        1
      ]
    }
  }
}

EvaluateRecommend

Format

{
  "from": From,
  "where": Proposition,
  "recommend": Get,
  "goal": Proposition,
  "select": Projection,
  "offset": integer,
  "limit": integer
}

Example

{
  "from": "impressions",
  "goal": {
    "purchase": "true"
  },
  "recommend": "product",
  "where": {
    "product.name": {
      "$get": "query"
    },
    "session.user": {
      "$get": "session.user"
    }
  }
}

EvaluateSimilarity

Format

{
  "from": From,
  "where": Proposition,
  "get": Get,
  "similarity": Proposition or PrimitiveProposition,
  "select": Projection,
  "offset": integer,
  "limit": integer
}

Referenced in

Example

{
  "from": "messages",
  "get": "product",
  "similarity": {
    "description": {
      "$get": "message"
    },
    "title": {
      "$get": "message"
    }
  }
}

ExponentPropositionArray

Referenced in

Example

[
  "width",
  2
]

ExponentPropositionObject

Format

{
  "base": Score,
  "exponent": Score
}

Referenced in

Example

{
  "base": "width",
  "exponent": 2
}

EmptyDocument

Referenced in

  • /api/v1/schema/_rename
  • /api/v1/schema/_copy

FieldProposition

Format

{
  "fieldName": Proposition or PrimitiveProposition
}

Referenced in

Example

{
  "from": "impressions",
  "where": {
    "click": true
  }
}

More examples

"impressions"
{
  "from": {
    "from": "impressions",
    "where": {
      "click": true
    }
  },
  "orderBy": "$p",
  "where": {
    "query": "laptop"
  }
}
{
  "from": "impressions"
}

Example

"impressions"

More examples

"products"
"customers"
"messages"

FromTablequery

Referenced in

Example

"impressions"

More examples

"products"
"customers"
"messages"

FromWhere

Format

{
  "from": From,
  "where": Proposition,
  "limit": integer
}

Referenced in

Example

{
  "from": "impressions",
  "where": {
    "click": true
  }
}

Example

{
  "$get": "query"
}

More examples

{
  "$get": "click"
}
{
  "$get": "product.title"
}

Goal

Referenced in

Example

{
  "purchase": true
}

More examples

{
  "click": true
}

Hits

Referenced in

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"
  }
]

Is

Format

{
  "$is": PrimitiveProposition
}

Referenced in

Example

{
  "$is": "value"
}

KnnPropositionArray

Referenced in

Example

[
  4,
  {
    "tags": "laptop"
  }
]

KnnPropositionObject

Format

{
  "k": integer,
  "near": Proposition or PrimitiveProposition
}

Referenced in

Example

{
  "k": 4,
  "near": {
    "tags": "laptop"
  }
}

NnPropositionArray

Referenced in

Example

[
  {
    "tags": "laptop"
  }
]

NnPropositionObject

Format

{
  "near": Proposition or PrimitiveProposition,
  "threshold": number
}

Referenced in

Example

{
  "near": {
    "tags": "laptop"
  }
}

ModPropositionArray

Referenced in

Example

[
  2,
  0
]

ModPropositionObject

Format

{
  "divisor": integer,
  "remainder": integer
}

Referenced in

Example

{
  "divisor": 2,
  "remainder": 0
}

OnPropositionArray

Referenced in

Example

[
  {
    "click": true
  },
  {
    "user.tags": "nyc"
  }
]

OnPropositionObject

Format

{
  "prop": Proposition,
  "on": Proposition
}

Referenced in

Example

{
  "on": {
    "user.tags": "nyc"
  },
  "prop": {
    "click": true
  }
}

Example

"product.price"

More examples

{
  "$asc": "product.price"
}
{
  "$desc": "product.price"
}
{
  "$multiply": [
    "$p",
    "prices"
  ]
}

RelateOrderBy

Referenced in

Example

{
  "$desc": "info.miTrue"
}

More examples

{
  "$asc": "lift"
}

Example

{
  "name": "My product",
  "price": 172.19
}

More examples

{
  "$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"
  }
}

Example

[
  "user.name",
  "query",
  "product.title",
  "click"
]

More examples

[
  "$why"
]

TestSource

Format

{
  "from": From,
  "where": Proposition,
  "offset": integer,
  "limit": integer,
  "select": Selection
}

Example

{
  "limit": 100,
  "select": [
    "query"
  ],
  "where": {
    "$index": {
      "$mod": [
        5,
        1
      ]
    }
  }
}

Example

{
  "name": "My product",
  "price": 172.19
}

Example

"product.id"