Skip to content

Query Input Overview

Loris Sauter edited this page Jul 4, 2024 · 3 revisions

InputData is the class name of the query input, which can be seen as the actual payload of a query (or the data, hence the name).

Due to vitrivr-engine's type system (and being written in a typed language), InputData is strongly typed. All input datas have in common, that the general JSON representation looks as follows:

{
  "type":"<type>",
  "comparison":"<comparison>",
  "data":"<payload>"
}

See below for the individual placeholders. The comparison property is optional.

⚠️ NOTE: The ID input data has no data property, but an id property! ⚠️

Input Types

The input types are for various use-cases.

Input Type Description Type Syntax Use Case (non-exhaustive)
TEXT Textual input "text" (string) Used with textual extractors (OCR, ASR) or latent space embeddings (CLIP) or for LIKE comparisons
VECTOR Vector input [0.1,2.3,...] (list of numbers) Used with vector based analysers, e.g. the average colour
IMAGE Image input base64 encoded dataurl of the image (string) Used for analysers which can work with images directly, e.g. DINO
ID ID input "65f83719-b350-4690-80d2-10c558c1fcf2" (string) A retrievable ID, for direct lookup
BOOLEAN Boolean input true OR false (Boolean) For boolean comparisons, e.g. if a field should be true or false
NUMERIC Numberic input 1.5 (Number) For numeric comparisons, e.g. compare resolutions or similar, number based values
DATE Date input YYYY-mm-dd (Simple Date) For date based comparisons. Since this is only date-based, the time is not respected.

Comparison

The comparison property is optional and designed for Boolean retrieval (and does not have a semantic otherwise). It is read such that the comparison is applied as an operator and the input data is the left-hand operand of the expression.

These comparison operators are directly mapped to CottontailDB ComparisonOperators.

Comparison Symbol Description CottontailDB ComparisonOperator
< Less than, this is primarily for numerical comparisons, however strings (text) are lexicographically compared and for dates the semantic is 'earlier' LE
<= Less or equal than, this is primarily for numerical comparisons, however strings (text) are lexicographically compared and for dates the semantic is 'earlier or at the same date' LEQ
== Equal comparison, which in this case is similar to the the identity comparison. Strings are case sensitive. EQ
!= Not equal comparison NEQ
>= Greater or equal than, this is primarily for numerical comparisons, however strings (text) are lexicographically compared and for dates the semantic is 'later or at the same date' GEQ
> Greater than, this is primarily for numerical comparisons, however strings (text) are lexocographically compared and for dates, the semantic is 'later' GE
~= An SQL-based LIKE comparison, including the rules for SQL-LIKE placeholders. LIKE
Clone this wiki locally