Skip to content
Open
5 changes: 3 additions & 2 deletions docs/developers/search-v3-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ A named query identifies a field only when that field is its own clause. A `mult

A structured-property match reports the definition URN and the matched value. It also reports `exact`, `prefix`, `contains`, or `nameAndValue` when the matching clause has that `_name` and names one structured-property field. The author writes `exact`, `prefix`, or `contains` on the clause. The executor writes `nameAndValue` on the expanded name-and-value clause. A missing name, a reused name, or a clause that names several properties leaves the mode unset. The report does not invent one. Shared-field matches stay indexed names. Write time does not require these names. The report is what a result card uses to show the value that matched. Result-card layout stays outside this contract. It is a companion dependency of this Search V3 result.

The comparison uses values on the returned document. A shared field filled only by `copy_to` is not stored, which keeps that cost off every write, so the check reads the source fields copied into it. A keyword is the value itself, folded the same way as the folded copy when the match was case-insensitive. Analyzed text uses the same approximate mark the UI applies. That mark can miss a hit found only through a stem, a fuzzy edit, a synonym, or a phrase with slop. The drift is accepted. The engine highlighter stays off on a template request.
The comparison uses values on the returned document. A shared field filled only by `copy_to` is not stored, which keeps that cost off every write, so the check reads the source fields copied into it. A keyword is the value itself, folded the same way as the folded copy when the match was case-insensitive. Analyzed text uses the same approximate mark the UI applies. That mark can miss a hit found only through a stem, a fuzzy edit, a multi-word synonym, or a phrase with slop. A one-word synonym of the query or of one of its words counts, after a typed word. The drift is accepted. The engine highlighter stays off on a template request.

Shipped templates leave `highlightFields` unset, so the default set is empty. A template opts fields in only when that cost is warranted. A child changes the set with `add`, `remove`, and `replace`. `replace` cannot be combined with `add` or `remove`. An explicit empty section clears the set. A request applies the same section after the template set. `customHighlightingFields` replaces that set outright, including a V2 subfield normalized to its indexed root, and the request section is not applied on top of it. `skipHighlighting` then clears whatever remains. The section has no weight. It names an indexed field, including a degree field such as `tags_1` and a structured property such as `structuredProperties.tier`, which is read where it is stored because `copy_to` does not put its value on the shared field. A field this query does not read, an aspect path, a wildcard, or a subfield the index does not store is dropped. The engine highlighter stays off. A non-empty set fetches those source paths, including the fields copied into a selected shared field, and matches them on the final page.

Expand Down Expand Up @@ -827,7 +827,8 @@ The builder rewrites the query before any clause sees it. The service computes t
| `unquoted` | `raw` with one pair of surrounding quotes removed. |
| `shortened` | `normalized` cut on a word boundary. |
| `lastSegment` | The last `.` / `_` / `-` / `/` segment of `raw`. |
| `synonyms` | The synonym list for the whole query. |
| `synonyms` | The synonyms of the whole query and of each of its words. |
| `exactSynonyms` | Synonyms of the whole query only, for a clause that must not use a word's synonym, such as an exact name. |

Shape flags are computed by the service and referenced from the body:

Expand Down
4 changes: 2 additions & 2 deletions docs/how/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,13 @@ Stable Mustache names for version 1 are the public context. A template parameter
| `entityNameField`, `nameKeyword`, `nameText`, `qualifiedNameKeyword`, `qualifiedNameText`, `qualifiedNameIdentity`, `descriptionField`, `descriptionText`, `platformField`, `columnNameField`, `idKeyword`, `urnExactField`, `urnFoldedField`, `urnParsedField`, `urnKeyword`, `wildcardFields`, `prefixFields` | Schema paths, with a fixed fallback when the index does not have the field. `wildcardFields` is present for a single token of at least `wildcardMinimumLength`. Each element has `field` and `boost` (`fieldBoost * 0.3`) for an analyzed `name` or `title` field. `prefixFields` is present when prefix matching is on. Each element has `field` and `boost` (`fieldBoost * prefixFactor * caseFactor * 6`) for an analyzed `name` or `qualifiedName` `.text` or `.stemmed` field. `exact` and `structured` keep one `nameText` prefix at `prefixFactor`. |
| `prefixFactor`, `exactFactor`, `caseSensitivityFactor`, `twoGramFactor`, `threeGramFactor`, `fourGramFactor`, `urnFactor`, `partialFactor`, `fuzzyMaxExpansions`, `prefixMaxExpansions` | Weights and expansion caps from search configuration and the clause budget. |
| `structuredQuery` | JSON for the structured `/q` clause. Present on the `structured` and `structuredExact` templates. Splice it with `{{&structuredQuery}}`. |
| `flags`, `synonyms`, `multiWord`, `longQuery`, `dottedQuery`, `fullyQualifiedName`, `deepPath`, `longExactName`, `operatorEscaped`, `spacelessIdentifier`, `letterDigitParts`, `fqnParts` | Shape flags. `synonyms` is a list and is omitted when empty. `flags.alphanumericSplit` and `flags.exactNameLetterDigit` are booleans. `flags.exactNameLetterDigit` is true for one exact-name token that splits at a letter/digit boundary. |
| `flags`, `synonyms`, `exactSynonyms`, `multiWord`, `longQuery`, `dottedQuery`, `fullyQualifiedName`, `deepPath`, `longExactName`, `operatorEscaped`, `spacelessIdentifier`, `letterDigitParts`, `fqnParts` | Shape flags. `synonyms` (the synonyms of the whole query and of each word) and `exactSynonyms` (of the whole query only) are lists and are omitted when empty. `flags.alphanumericSplit` and `flags.exactNameLetterDigit` are booleans. `flags.exactNameLetterDigit` is true for one exact-name token that splits at a letter/digit boundary. |
| `entityTypes`, `valueScoreFunctions`, `fieldScoreFunctions` | Entity names, and `@SearchScore` data. A value function has `field`, `valueJson`, and `weight`. A field function has `field`, `factor`, `missing`, and sometimes `modifier`. |
| `viewerUrn`, `viewerGroupsJson`, `viewerDomainsJson`, `domainsJson` | Caller values a boost or clause may inject. Authorization filters stay outside the template. |

These aliases are still filled and are not part of the public contract: `defaultQueryFields` (the list behind `defaultQueryFieldsJson`), `unquotedQuery`, `fuzzyQuery`, `synonymQueries`, `longPhrase`, `dotted`, and `urnField`. `synonymPriority` is set only while a write is checked. Search execution does not set it. `{{.}}` is the current synonym, not a named variable. A `{{&name}}` hole such as `extraDisMaxQueries` is query JSON, not a context variable.

`{{{name}}}`, a Mustache delimiter change, and `{{&query}}`, `{{&raw}}`, `{{&escaped}}`, and `{{&unquoted}}` are rejected. `{{&name}}` is only for server-built JSON (`structuredQuery` and names ending in `Json`) and for fragment holes. The rendered body is checked again for `script`, `script_score`, `wrapper`, `percolate`, `min_score`, and terms lookups. `escaped` backslash-escapes `\` before `+ | - * ( ) ~ "`. `maxLeafClauses` applies to the write-time sample, which repeats `synonyms` to the synonym cap, and to the live query.
`{{{name}}}`, a Mustache delimiter change, and `{{&query}}`, `{{&raw}}`, `{{&escaped}}`, and `{{&unquoted}}` are rejected. `{{&name}}` is only for server-built JSON (`structuredQuery` and names ending in `Json`) and for fragment holes. The rendered body is checked again for `script`, `script_score`, `wrapper`, `percolate`, `min_score`, and terms lookups. `escaped` backslash-escapes `\` before `+ | - * ( ) ~ "`. `maxLeafClauses` applies to the write-time sample, which repeats `synonyms` and `exactSynonyms` to the synonym cap, and to the live query.

A template cannot include a Mustache partial. `rescore` cannot be combined with `sort` or with `functionScore.boost_mode: replace`: the search engine rejects rescore when the request has an explicit sort. With a rescore and no caller sort, DataHub omits the `urn` tie-break. A caller sort replaces the rescore. Checks run on the template after parent sections are merged, so a child that adds a `rescore` to a parent with `boost_mode: replace` is rejected.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,17 @@ private static void scanFields(
@Nonnull Map<String, Set<String>> matched,
@Nonnull List<MatchEvidence> ordinary,
boolean explain) {
if (!fields.labelKeys().isEmpty()) {
addFirst(matched, ordinary, matcher.matches(source, fields.labelKeys(), Map.of(), explain));
}
if (!fields.fallbackPaths().isEmpty()) {
if (!fields.labelKeys().isEmpty() || !fields.fallbackPaths().isEmpty()) {
// One scan over a label's key and its fallback paths, so a typed match on any of them is
// reported ahead of a synonym-only one.
List<String> labelPaths = new ArrayList<>(fields.labelKeys());
fields.fallbackPaths().stream()
.filter(path -> !labelPaths.contains(path))
.forEach(labelPaths::add);
addFirst(
matched,
ordinary,
matcher.matches(source, fields.fallbackPaths(), fields.fallbackLabels(), explain));
matcher.firstPerName(source, labelPaths, fields.fallbackLabels(), explain));
Comment thread
alexjst marked this conversation as resolved.
Resolved
}
if (!fields.direct().isEmpty()) {
addFirst(matched, ordinary, matcher.matches(source, fields.direct(), Map.of(), explain));
Expand Down
Loading
Loading