How to search data with a prefix using ArcQL

In the previous posts, we have seen how to search null and non-null data.

Now we will check how to search data starting with a prefix using the arcql prefix query

  • Prefix query returns results starting with given prefix.
  • AND/ OR Boolean logic is possible to get the specific record
  • Frame a query like this.
a ^ 'some string' OR 123

We will work with the same schema used earlier.

type arcqlObject {
    str: String
    int: Int
}

Sample Query

Let’s search the prefix easy in the str field .

{
  find(type: arcqlObject, arcql: "str ^ 'easy'") {
    edges {
      node {
        ... on arcqlObject {
          str
          hypi {
            id
          }
        }
      }
      cursor
    }
  }
}
#result
{
  "data": {
    "find": {
      "edges": [
        {
          "node": {
            "str": "easy to use backend",
            "hypi": {
              "id": "01FJGS5P4ECE8BSG10FVJ1865V"
            }
          },
          "cursor": "01FJGS5P4ECE8BSG10FVJ1865V"
        }
      ]
    }
  }
}

Query Variables

query GetPrefixRecord($type: HypiMutationType!, $arcql: String!) {
  find(type: $type, arcql: $arcql) {
    edges {
      cursor
      node {
        ... on arcqlObject {
          hypi {
            id
          }
          str
          int
        }
      }
    }
  }
}
#query variables
{
  "type": "arcqlObject",
  "arcql": "str ^ 'easy'"
 }

Check the POSTMAN collection for the prefix 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!
Run in Postman