In the previous post, we have seen how to search exact data using the term query.
Now we will check how to search a phrase from the data using the arcql phrase query
- Phrase query returns results matching the individual words or exact phrases.
- AND/ OR Boolean logic is possible to get the specific record
Frame a query like this.
a ~ 'some string' OR `abc`
We will work with the same schema used earlier.
type arcqlObject {
str: String
int: Int
}
Sample Query
Let’s search the phrase low
in the str
field with int
value 3.
{
find(type: arcqlObject, arcql: "str ~ 'low' AND int = 3") {
edges {
node {
... on arcqlObject {
str
int
hypi {
id
}
}
}
cursor
}
}
}
#result
{
"data": {
"find": {
"edges": [
{
"node": {
"str": "low code",
"int": 3,
"hypi": {
"id": "01FJ9PZGEKEHFBCGG9CYT47PYX"
}
},
"cursor": "01FJ9PZGEKEHFBCGG9CYT47PYX"
}
]
}
}
}
Please note str ~ 'low'
is a phrase query and int = 3
is a term match as shown in the previous post.
Query Variables
query GetPhrase($type: HypiMutationType!, $arcql: String!) {
find(type: $type, arcql: $arcql) {
edges {
cursor
node {
... on arcqlObject {
hypi {
id
}
str
int
}
}
}
}
}
#query variables
{
"type": "arcqlObject",
"arcql": "str ~ 'low' AND int = 3"
}
Check the POSTMAN collection for the phrase 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!