1 QuerySyntax
j edited this page 2023-07-02 12:57:13 +05:30

Query Syntax

[Documents, pandora*, 0xdb2*)]TOC(heading=Design

Simple query

query: {
    conditions: [
        {
            key: "year",
            value: [1970, 1980],
            operator: "!-"
        },
        {
            key: "country",
            value: "f",
            operator: "^"
        }
    ],
    operator: "&"
}

Complex query

query: {
    conditions: [
        {
            conditions: [
                {
                    key: "year",
                    value: 1960,
                    operator: "<"
                },
                {
                    key: "year",
                    value: 1960,
                    operator: ">"
                },
                {
                    key: "title",
                    value: "sex",
                    operator: ""
                },
            ],
            operator: "|"
        },
        {
            key: "director",
            value: "jean-luc godard",
            operator: "="
        }
    ],
    operator: "&"
}

Objects

query: {conditions, operator}
conditions: [query|condition]
condition: {key, value, operator}

Operators

string
x: contains
!x: does not contain
^x: starts with
!^: does not start with
x$: ends with
!$: does not end with
^x$: is
!^x$: is not

number
x: is
!x: is not
<x: is less than
>x: is greater than or equal to
x-x: is between
!x-x: not between

conditions
a,b: a and b
a|b: a or b

Examples

foo
keyword:foo
year:1980,hello,country:usa
year:1980,hello,country:!usa
title:!^the
title:^the$
title:^100%24$
year:>1960,year:<1970
year:<1960|year:>1970|title:sex
profit:-1000000-1000000
profit:-1000000--500000
releasedate:1970-10-1970-12
releasedate:1970-1972-12-13
[year:<1960|year:>1970|title:sex],director:godard // group godard will be selected
[year:<1960|year:>1970|title:sex],[director:godard|director:scorsese] // groups godard and scorsese will be selected
director:godard,country:france,year:1967 // groups godard, france and 1967 will be selected
list:mylist,director:hitchcock
list:otheruser.publiclist,director:hitchcock
list:0xdb.timelines,director:hitchcock

Recursion

list:you.yourlist,list:!mylist (both dynamic)
... save as wishlist
... edit mylist to be wishlist
... now wishlist is: you.yourlist,!wishlist -> recursion
so if you change a dynamic list to contain a reference to itself,
you will get a recursion error.
which means that we'll need to add to the API a request like
function:norecursion,data:mydynamiclist
that returns a list of recursion-safe public dynamic lists

URLs

0xdb.org/#find=title:foo,director:!bar&sort=country,-year&view=icon,poster
0xdb.org/?find=title:foo,director:!bar&sort=country,-year&view=icon,poster // do we need this for search engines?