In Augmented Search, how do I search for exact terms, and how do I walk a tree facet recursively?
Question
In Augmented Search, how do I search for exact terms, and how do I walk a tree facet recursively?
Answer
Exact terms: turn fuzziness off
If you have read that fuzziness is not customizable, that is out of date. An older knowledge base entry says so. The current GraphQL schema exposes a
fuzzyargument onsearch, and the module reads its defaults from OSGi configuration - both shown below. Which Augmented Search release introduced the argument was not established; if you are on an older one, check your own schema before assuming.
Augmented Search is fuzzy by default. The shipped default is one character
change, so fuzziness = ONE - which is why a search for form also returns
farm, and why results look wrong when you expected exact matching.
Set it to NONE on the query:
{
search(
q: "annual report"
siteKeys: ["mySite"]
fuzzy: {fuzziness: NONE}
) {
results { displayableName path }
}
}
fuzziness is nested inside fuzzy, not a top-level argument. Writing
search(q: "...", fuzziness: NONE) is a schema validation error - there is no
such argument on search. The nesting exists because fuzzy also carries
expansions, prefix and transpositions.
The enum has four values:
| Value | Meaning |
|---|---|
NONE | no fuzziness - exact terms |
ONE | at most 1 character change - the default |
TWO | at most 2 character changes |
AUTO | by term length: 0 for 1-2 chars, 1 for 3-5, 2 for more |
NONE overrides everything else in the fuzzy block. The other parameters -
expansions, prefix, transpositions - are disregarded when fuzziness is
NONE, so there is no point tuning them alongside it.
Changing it for every query
If exact matching is what the site should do by default, set it once in the module's OSGi configuration rather than on every query:
org.jahia.modules.augmentedsearch.fuzziness=NONE
Related keys, with their defaults, in the same namespace:
| Key | Default |
|---|---|
.fuzziness | ONE |
.fuzzyMinTermLength | 4 |
.fuzzyMaxTermLength | 200 |
.fuzzyMaxExpansions | 10 |
.fuzzyPrefixLength | 2 |
.fuzzyTranspositions | true |
fuzzyMinTermLength is worth knowing on its own: fuzzy matching is not applied to
terms shorter than 4 characters at all, so short queries already behave exactly
and only longer ones appear to misbehave.
Tree facets are not recursive in one call
treeFacet returns one level - the children of the rootPath you pass. There
is no depth parameter. You walk the hierarchy by issuing one query per level.
{
search(q: "", siteKeys: ["mySite"]) {
treeFacet(field: "jgql:categories_path.facet", rootPath: "/music") {
rootPath
data {
value
count
hasChildren
rootPath
humanPath
filter
}
}
}
}
The two fields that make the walk work:
hasChildren- whether this entry has anything below it, so you know whether drilling down is worth a round trip.rootPathon each entry - described in the schema as "System path to be used in root path for tree facets". Feed it straight back as therootPathof the next query. Do not build the child path by string concatenation fromvalueorhumanPath;humanPathis for display.
filter on each entry is the filter expression that selects the results under
that path, which is what you apply when the user clicks the facet.
Other arguments: max (default 10) caps the number of groups returned - raise it
if a level is truncated - minDocCount (default 1), missingValue to bucket
entries with no value, and disjunctive which controls whether the aggregation
runs against the full filter or against the filter minus this facet's own field,
the usual choice for multi-select facets.
This article was drafted with AI assistance, then reviewed and curated by Jahia Customer Support engineers before publication.