Skip to content

SearchIndexContext

Collects the text and facets that describe one Item in a search index.

Text is matched by search terms; facets are exact key:value strings matched by facet queries. Every method ignores undefined and empty input, so Property values can be passed without checks.

SearchIndexHandler

email(key): this

Adds email:<address> and emailDomain:<domain> facets for an email address.

string | undefined

Email address, or undefined to add nothing.

this

This context for chaining.

The address is trimmed and lowercased. Input that is not an email address is ignored.


facet(key): this

Adds a facet, conventionally in the form key:value such as tier:team.

string | undefined

Facet string, or undefined to add nothing.

this

This context for chaining.

The facet is trimmed and truncated to 256 characters. An Item may carry at most 128 facets.

When the Item already carries the maximum number of facets.


text(text, weight?): this

Adds text to the Item’s searchable content, optionally at a higher weight.

string | undefined

Text to index, or undefined to add nothing.

25 | 50 | 75 | 100

Ranking weight of this text.

this

This context for chaining.

Text may be added several times; entries of the same weight are concatenated. Each entry is truncated to 16,384 characters. Higher weights rank matches higher: 100 is the highest and 25 the lowest.

25

Weighting the title above the body

ctx.text(item.properties.title, 100).text(item.properties.body);

uuid(key): this

Adds a uuid:<id> facet for an identifier.

string | { id: string; } | undefined

UUID, object with an id, or undefined to add nothing.

this

This context for chaining.

Accepts a string or any object with an id, such as an Item. The value is trimmed and lowercased; input that is not a UUID is ignored.