Skip to content

Instantly share code, notes, and snippets.

@steve-todorov
Forked from sbespalov/readme.md
Last active March 23, 2018 10:13
Show Gist options
  • Save steve-todorov/723a3bd4ae5d89c7895febaf4294278e to your computer and use it in GitHub Desktop.
Save steve-todorov/723a3bd4ae5d89c7895febaf4294278e to your computer and use it in GitHub Desktop.
AQL Syntax

Introduction

Searching for artifacts should be easy and consistent across all layouts. This is where Artifact Query Language (or AQL for short) comes into play. It needs to be able to provide a way for the end user to easily find what they are looking for.

Artifact Query Language

Search queries are constructed using Tokens where each token is a pair of <key>:<value> separated with :.

AQL Keys

The full list of possible keys will vary depending on the enabled layout providers, but the following common list needs to work the same across all layouts:

Key Description
storage Search for artifacts in a specific storage id
repository Search for artifacts in a specific repository id
layout Search for artifacts in a specific repository layout
tag Search for artifacts with available tag name
from Search for uploaded artifacts starting date (unicode format, results include the date)
to Search for uploaded artifacts before date (unicode format, results include the date)
age Constant: day, month, year, etc.
asc Order results ascending
desc Order results descending

The list below shows the keys for each specific layout.

Layout Key Description
Maven groupId Search by group id
artifactId Search by artifact id
version Search by version
Nuget id Search by id
version Search by version
NPM scope Search by scope
name Search by name
version Search by version

AQL Values

  • Values can be strings:

    • quoted with single quotes ' when the value is more than one word (Valid Examples: storage: storage0, layout: 'Maven 2')
    • separated with comma , for multiple values; you can consider this the same as IN operator in SQL (Valid Examples: repository: releases, snapshots, layout: 'Maven 2', NuGet)
    • wildcards are supported * (Valid Examples: group: org.carlspring.*)
  • Values can be dates in unicode format: 2018-03-21 13:00:00, 2018-03-21 (Valid Examples: updated: 2018-03-21, updated: '2018-03-21 13:00')

  • Values can be keywords/constants: day, month, year, etc. (Valid Examples: age: >= 30d)

Query expression

  • Queries are composed using Tokens to create an expression:
    storage:storage0 repository:releases
    

 

  • Expression parts can be surrounded by round brackets for more advanced queries. The following examples are equal:
    storage:storage0 repository:releases
    
    (storage:storage0)(repository:releases)
    
    ((storage:storage0) (repository:releases))
    

 

  • Expression parts can be joined by logical operators:
    • AND is implied by default and means logical conjunction (equivalent synonymous: &,&&)
    • OR means logical disjunction (equivalent synonymous: |,||)
    • The following examples are equal:
      storage:storage0 repository:releases
      
      (storage:storage0)(repository:releases)
      
      (storage:storage0) AND (repository:releases)
      
      storage:storage0 && repository:releases
      

 

  • Expression parts can be prefixed with + and - for inclusion or negation.
    • + is implied by default and means no negation (by and large does not mean anything, you can use it simply for clarity)
    • - means logical negation
    • The following examples are equal:
      storage:storage0 repository:releases NOT groupId: 'org.carlspring'
      
      storage:storage0 AND +repository:releases AND NOT groupId: 'org.carlspring'
      
      +(storage:storage0)+(repository:releases)-(groupId: 'org.carlspring')
      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment