In the previous post, we have seen how to search data using the arcql wildcard query.
Now we will check how to search the data within a given range using the Range Query.
- Frame queries like this.
a IN (0, 1] => left inclusive => including 1, excluding 0
a IN [0, 1) => right inclusive => excluding 1, including 0
a IN (0, 1) => exclusive => not including 0 or 1, only those in between
a IN [0, 1] => inclusive => including both 0, 1 and everything in between
- Use Boolean logic to combine range search
- It works for strings as well. The strings are ordered alphabetically.
We will work with the below schema.
type ArcqlObj {
strFld: String
intFld: Int
floatFld: Float
}
Let’s insert values in the ArcqlObj.
mutation {
upsert(
values: {
ArcqlObj: [
{ strFld: "hypi", intFld: 30, floatFld: 2.3 }
{ strFld: "low code", intFld: 98, floatFld: 1.2 }
{ strFld: "easy to use backend", intFld: 33, floatFld: 1.1 }
]
}
) {
id
}
}
Sample Query
Right Inclusive
Below query searches the values between 1.1 and 1.2. The result excludes 1.1 but includes 1.2.
{
find(type: ArcqlObj, arcql: "floatFld IN (1.1, 1.2]") {
edges {
node {
... on ArcqlObj {
strFld
intFld
floatFld
}
}
cursor
}
}
}
#result
{
"data": {
"find": {
"edges": [
{
"node": {
"strFld": "low code",
"intFld": 98,
"floatFld": 1.2
},
"cursor": "01FKZTAQPE31XPBYHR61V476HN"
}
]
}
}
}
Left Inclusive
Below query searches the values between 30 and 33. The result excludes 33 but includes 30.
{
find(type: ArcqlObj, arcql: "intFld IN [30, 33)") {
edges {
node {
... on ArcqlObj {
strFld
intFld
floatFld
}
}
cursor
}
}
}
#result
{
"data": {
"find": {
"edges": [
{
"node": {
"strFld": "hypi",
"intFld": 30,
"floatFld": 2.3
},
"cursor": "01FKZTAQPDK5FKH3P7K6S5S58Q"
}
]
}
}
}
Exclusive
Below query searches the values between 30 and 98 excluding both.
{
find(type: ArcqlObj, arcql: "intFld IN (30, 98)") {
edges {
node {
... on ArcqlObj {
strFld
intFld
floatFld
}
}
cursor
}
}
}
#result
{
"data": {
"find": {
"edges": [
{
"node": {
"strFld": "easy to use backend",
"intFld": 33,
"floatFld": 1.1
},
"cursor": "01FKZTAQPEVFZVAGA4J80PETEY"
}
]
}
}
}
Inclusive
Below query searches the values between two strings, including both.
{
find(type: ArcqlObj, arcql: "strFld IN ['easy to use backend', 'low code']") {
edges {
node {
... on ArcqlObj {
strFld
intFld
floatFld
}
}
cursor
}
}
}
#result
{
"data": {
"find": {
"edges": [
{
"node": {
"strFld": "hypi",
"intFld": 30,
"floatFld": 2.3
},
"cursor": "01FKZTAQPDK5FKH3P7K6S5S58Q"
},
{
"node": {
"strFld": "low code",
"intFld": 98,
"floatFld": 1.2
},
"cursor": "01FKZTAQPE31XPBYHR61V476HN"
},
{
"node": {
"strFld": "easy to use backend",
"intFld": 33,
"floatFld": 1.1
},
"cursor": "01FKZTAQPEVFZVAGA4J80PETEY"
}
]
}
}
}
Check the POSTMAN collection for the range query
in different programming languages! Click </>
and choose the programming language of your choice.
Don’t forget to insert your own Authorization key and Hypi Domain under Headers to test the results!