Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

UniqueQL

Postgres

Qdrant

Code Block
languagetypescript
const query = {
  path: ['id'],
  operator: Operator.EQUALS,
  value: 1,
};

Code Block
languagesql
SELECT metadata 
FROM "public"."Content" 
WHERE  
  jsonb_path_exists(
    metadata,         
    '$ ? (exists(@.id ? (@ == 1)))'
  );

Code Block
languagejson
{
  "key": "metadata.id",
  "match": {
    "value": 1
  }
}
Code Block
languagetypescript
const query = {
  path: ['time'],
  operator: Operator.GREATER_THAN,
  value: new Date('2025-11-09'),
};
Code Block
languagesql
SELECT metadata 
FROM "public"."Content" 
WHERE 
  jsonb_path_exists(
    metadata, 
    '$ ? (
      exists(
        @.time ? (
          @.datetime("YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"") > 
              "2025-11-09T00:00:00Z".datetime()
        )
      )
    )'
  );
Code Block
languagejson
{
  "key": "metadata.time",
  "match": {
    "range": {
      "gt": "2025-11-09T00:00:00Z"
    }
  }
}
Code Block
languagetypescript
const query = {
  path: ['diet', '*'],
  operator: Operator.NESTED,
  value: {
    and: [
      {
        or: [
          {
            path: ['food'],
            operator: Operator.EQUALS,
            value: 'meat',
          },
          {
            path: ['food'],
            operator: Operator.EQUALS,
            value: 'vegis',
          },
        ],
      },
      {
        path: ['likes'],
        operator: Operator.EQUALS,
        value: true,
      },
    ],
  },
};
Code Block
languagesql
SELECT metadata 
FROM "public"."Content" 
WHERE jsonb_path_exists(
    metadata, 
    '$ ? (
        exists(@.diet[*] ? (
            (
                exists(@.food ? (@ == "meat")) 
                || exists(@.food ? (@ == "vegis"))
            ) 
            && exists(@.likes ? (@ == true))
        ))
    )'
);
Code Block
languagejson
{
  "nested": [
    {
      "key": "metadata.diet[]",
      "filter": {
        "must": [
          {
            "should": [
              {
                "key": "food",
                "match": {
                  "value": "meat"
                }
              },
              {
                "key": "food",
                "match": {
                  "value": "vegis"
                }
              }
            ]
          },
          {
            "key": "likes",
            "match": {
              "value": true
            }
          }
        ]
      }
    }
  ]
}

Working with Dates

Dates must be formated in the Data and in the Query like so:

Code Block
2025-11-09T00:00:00Z

This is important as Qdrant only supports this format. Else you might experience an error.

Examples

When designing a search or query system for specific use cases, UniqueQL can be applied to create precise queries that match the requirements. Below are examples of how you might structure UniqueQL queries for the use cases you've mentioned:

...