This methods add/remove fields to an existing document.
This is useful to patch some fields in an existing document without having to replace it.
Example:
addFields
const miniSearch = new MiniSearch({ fields: ['title', 'text', 'author'] })
miniSearch.add({ id: 1, title: 'Neuromancer' })
miniSearch.addFields(1, {
text: 'The sky above the port was the color of television, tuned to a dead channel.',
author: 'William Gibson'
})
// The above is equivalent to:
miniSearch.add({
id: 1,
title: 'Neuromancer',
text: 'The sky above the port was the color of television, tuned to a dead channel.',
author: 'William Gibson'
})
removeFields
const miniSearch = new MiniSearch({ fields: ['title', 'text', 'author'] })
miniSearch.add({
id: 1,
title: 'Neuromancer',
text: 'The sky above the port was the color of television, tuned to a dead channel.',
author: 'William Gibson'
})
miniSearch.removeFields(1, {
text: 'The sky above the port was the color of television, tuned to a dead channel.',
author: 'William Gibson'
})
// The above is equivalent to:
miniSearch.add({
id: 1,
title: 'Neuromancer'
})
Resolves: #170
This methods add/remove fields to an existing document.
This is useful to patch some fields in an existing document without having to replace it.
Example:
addFields
removeFields