The options for the search index
The number of documents discarded since the most recent vacuuming
A number between 0 and 1 giving an indication about the proportion of documents that are discarded, and can therefore be cleaned up by vacuuming. A value close to 0 means that the index is relatively clean, while a higher value means that the index is relatively dirty, and vacuuming could release memory.
Total number of documents available to search
Is true
if a vacuuming operation is ongoing, false
otherwise
Number of terms in the index
Allows serialization of the index to JSON, to possibly store it and later deserialize it with loadJSONIndex or loadJSONIndexAsync.
Normally one does not directly call this method, but rather call the
standard JavaScript JSON.stringify()
passing the SearchIndex instance,
and JavaScript will internally call this method. Upon deserialization, one
must pass to loadJSONIndex or loadJSONIndexAsync the same options used to create the original
instance that was serialized.
// Serialize the index:
let searchIndex = createIndex({ fields: ['title', 'text'] })
addAll(searchIndex, documents)
const json = JSON.stringify(index)
// Later, to deserialize it:
searchIndex = loadJSONIndex(json, { fields: ['title', 'text'] })
A plain-object serializable representation of the search index.
A class to represent search index
Basic example: