filter.nodes.match
match(spec: MatchSpec): FilterHandle<MatchSpec>Categorical (allowlist) filter on a node property.
Hides nodes whose property value is not in oneOf. When regex is provided, it takes precedence over oneOf.
property: "category" is remapped internally to match node.category (the top-level field). Similarly property: "id" maps to node.id. Any other value selects from node.properties.
spec.property | string | Node property name. Special-cases 'category' and 'id' to top-level fields. |
spec.oneOf | string[] | Set<string> | Allowlist of values that pass the filter. |
spec.regex | RegExp | Regex to match the property value. Takes precedence over oneOf. |
spec.on | string | string[] | '*' | Restrict to a subset of node categories. Default: '*' (all). |
spec.includeNull | boolean | Keep nodes missing the property. Default: true. |
spec.invert | boolean | Invert pass/fail. Default: false. |
spec.id | string | Override the auto-generated handle id. |
Returns: FilterHandle<MatchSpec>
Examples
// Keep only Person and Company nodes
const onlyPeopleAndCompanies = api.filter.nodes.match({
property: "category",
oneOf: ["Person", "Company"],
});
// Keep nodes whose name matches a regex
const aNames = api.filter.nodes.match({
property: "name",
regex: /^A/i,
});