weaviate/weaviate · error

preset %q not known to stopword detector

Error message

preset %q not known to stopword detector

What it means

NewDetectorFromPreset builds a stopword Detector from a named preset by looking the name up in the package-level Presets map. The Presets map contains only "en" (English) and "none" (empty set). If the preset string is anything else, the lookup fails and this error is returned instead of silently producing a detector with no stopwords.

Source

Thrown at adapters/repos/db/inverted/stopwords/detector.go:52

	if err != nil {
		return nil, errors.Wrap(err, "failed to create new detector from config")
	}

	d.SetAdditions(config.Additions)
	d.SetRemovals(config.Removals)
	d.preset = config.Preset

	return d, nil
}

func NewDetectorFromPreset(preset string) (*Detector, error) {
	var list []string
	var ok bool

	if preset != "" {
		list, ok = Presets[preset]
		if !ok {
			return nil, errors.Errorf("preset %q not known to stopword detector", preset)
		}
	}

	d := &Detector{
		stopwords: map[string]struct{}{},
	}

	for _, word := range list {
		d.stopwords[word] = struct{}{}
	}
	d.preset = preset
	return d, nil
}

func (d *Detector) ReplaceDetectorFromConfig(config models.StopwordConfig) error {
	d.Lock()
	defer d.Unlock()

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Set preset to "en" for the English stopword list or "none" for no stopwords.
  2. If custom stopwords are needed, use additions/removals in StopwordConfig with NewDetectorFromConfig instead of an unsupported preset.
  3. Check for typos and case-sensitivity — the map lookup is exact-match lowercase.
  4. If a different language's stopwords are required, supply them via the additions field; no built-in preset exists.

Example fix

// before
sm, err := stopwords.NewDetectorFromPreset("english")
// after
sm, err := stopwords.NewDetectorFromPreset(stopwords.EnglishPreset) // "en"
Defensive patterns

Strategy: validation

Validate before calling

validPresets := map[string]bool{"en": true, "none": true}
if !validPresets[preset] {
    return fmt.Errorf("preset %q not supported; use \"en\" or \"none\"", preset)
}

Type guard

func isKnownStopwordPreset(p string) bool { return p == "en" || p == "none" }

Prevention

When it happens

Trigger: Calling stopwords.NewDetectorFromPreset with a preset name other than "en" or "none", e.g. "english", "EN", "de", or a language code for a language Weaviate does not ship a preset for.

Common situations: A developer configuring invertedIndexConfig stopwords preset in a collection schema typo's the preset name or assumes other language presets exist; a migration from another system passes an Elasticsearch-style language preset name.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/2d80c1a6d2cd440a. Report an issue: GitHub.