ElasticGraph Query API: String Prefix Filtering
Try these example queries by visiting the GraphiQL UI after booting locally.
Copied!
$ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always
ElasticGraph offers a predicate to support string prefix filtering:
startsWith
- Matches documents using prefix filtering.
When
null
is passed, matches all documents.
Here’s a basic example:
Copied!
query ArtistsPrefixedWithThe {
artists(filter: {
name: {
startsWith: {
anyPrefixOf: ["The "]
}
}
}) {
edges {
node {
name
}
}
}
}
By default, prefix searching is case-sensitive. To make it case-insensitive, pass ignoreCase: true
:
Copied!
query ArtistsPrefixedWithTheCaseInsensitive {
artists(filter: {
name: {
startsWith: {
anyPrefixOf: ["the "]
ignoreCase: true
}
}
}) {
edges {
node {
name
}
}
}
}