Tagging behavior when there are non-existent tags

Author: bwood21Created Jul 2, 2026Updated Jul 2, 2026

I'm expecting that tags work as a union (which they do, most of the time), but they seem to work as an intersection when a tag that is not in the dataset is included. When I run a search, I would expect that a tag that doesn't have any items assigned to it would not cause the overall result to be zeroed out like this. A workaround I've found is to use suggest:true but that doesn't entirely fit my use case. I have a set list of tags, but not every index I create contains every tag.

Is this intended behavior?

The docs state that it should give results that are tagged with at least one of the given tags:

Image

Sample code below:

const index = new FlexSearch.Document({
	document: {
		id: 'id',
		index: 'content',
		tag: 'species',
		store: true,
	},
	tokenize: 'forward',
})

index.add({ id: 0, species: 'cat', content: 'some text alpha' })
index.add({ id: 1, species: 'dog', content: 'some text alpha' })
index.add({ id: 2, species: 'fish', content: 'some text alpha' })
index.add({ id: 3, species: ['cat', 'dog'], content: 'some text alpha' })


let goodResult = index.search('alpha', { tag: { species: ['cat', 'fish'] }}) // Returns [0,2,3]
let badResult = index.search('alpha', { tag: { species: ['cat', 'TAG_NOT_IN_DATASET'] }}) // Returns nothing, when I expect it should return [0,3]
let workaroundResult = index.search('alpha', { tag: { species: ['cat', 'TAG_NOT_IN_DATASET'] }, suggest: true }) // Returns [0,3]