diff --git a/CHANGELOG.md b/CHANGELOG.md index f3786e26..080843ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ `MiniSearch` follows [semantic versioning](https://semver.org/spec/v2.0.0.html). +# v6.3.0 + + - Add `queryTerms` array to the search results. This is useful to determine + which query terms were matched by each search result. + # v6.2.0 - Add the possibility to search for the special value `MiniSearch.wildcard` to diff --git a/README.md b/README.md index 70220053..9b66326b 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Alternatively, if you prefer to use a ` + ``` In this case, `MiniSearch` will appear as a global variable in your project. diff --git a/docs/assets/search.js b/docs/assets/search.js index a559733a..08b9dd17 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE81cXZObOhL9L86r1zEISTBv2WSzdbcqm7ubrZuHqakpxmZmuPEMswZPvir/fZEQ0I27scE4m5c710FHfdSnuyWB4Ptsm33OZxeX32ef0sf17MKfzx7jh2R2MXuXPqYfkni7up/NZ7vtpvynh2y92yT5y/bS4r542JTXV5s4z5Oyo9nsx7zpaxlpT7Y9VpD3T0WaPeZNp8XXJ9wlakYYmM+e4m3yWGCOrVklpVCN0etrY2CItRcN5JBRDAYUvKUfNAxu02SzHjRex2DRIIcRWbgBsHw2RbIdx8chT+UzkUSOkOv/L8FYZvXAGIfdZFlejKFXA38Vd1k+tbe80d6qhsU463OS3t0Xo8K9hf4qDnOMGpctR/usHhuXk7tv375OwnBhuzpBXdwjR/hpm9ymX6ZhXPV1dso2bN9kq92D6XVs+oAOfpUoRbxqv/qnpXczzMn1b5DTTmpjE6gGTsrmIf7ydiwhgJ2U0yp7uEkfk49pcT+GFoZPyqzIPiWP6bdRsQ+wv0o61pTqTAxHZ2IzODYJs1WS5/9Jtg/jMhHCfxX3AVa1B9VoD8IhctPCgy9HVd0Kd6rbupukg9ujn7UxGrklOnEzdNo26Lh6k67fmh6HkWhBE7HIi2ybvB3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BX+DfkNOkfp6K8gvmNDulfEJ6gJRUHM/qYAYIAAUDgEOZd6v+zM1b8sAcSCvNFZ36E0XAm0B1wQWce+kfaAd0l5wxi0rt1z0AEigQ8Pa+7OWjBysc55hSb3LaEsCtiuVbgfdnLgEiVXHal+i0PkLeQgHpesnPTWHEctIDzvK5cN1fgYcwVl1Scq5238Iq7Me9gGUQTb5jLrih/7f6pAFwGJiyJWfZolbwkw8gSkBUSs5s/VoVyAEA01wJq2DdlQIQSnPFqHl9B+CAn0IusNz3O8Dw4Mzp5l3JTdr7QaUA2ZAjmzfnOh7M2W+ABrkQceIg9Eu+LxCgERegFZoKbxCnLsQ40ao+tu77OcCTYDABVxXyziSLpnbWYme7pWFWLVmvm8l1f271gEmftQi+OwVGCGYe4W47BFykmTTeX8eCGI36kHgfDVCBu1cScLWryLrTkQIhHnEZ3H59EbgKzrShCwsuN+rzbkAmuPVbcnz39/4S8A05vhVsBT6XAWoeSAXZb5e6cQBGLbn1U30mDVR6mEIep23zHX8gDxgth2peIQc0QeWRrnBpUpyr+ewpfUo25V55dnF59ePH/wBCqqPT2mQAAA=="; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE81d23LbOBL9F+VVq4gEAZJ+yyaTrdmqbGY3U5MHl8tFS7TNsSx6RMq5Vf59CRAku6luSrwok5fRyMJBH/TpbgAkyHyb7dJP2ezi8tvsIdmuZxfufLaNHuPZxexdsk0+xNFudT+bz/a7TfGnx3S938TZy+anxX3+uCl+X22iLIuLjmaz7/O6r2XoO7LpsYS8f8qTdJvVneZfnnCXqBlhYD57inbxNsccG7NKSqFqo9fX2kAfay9qyDGjGAwoOEvXqxncJvFm3Wu8lsGiRvYjsrADYPls8ng3jI9FjuUzkUSWkO3/H95QZtXAGIfdpGmWD6FXAX8Wdxk+lbecwd4qh8U461Oc3N3ng8K9gf4sDrOMapctB/usGhuXk/uvX79MwnBhuhqhLu6RI/y0i2+Tz9MwLvs6O2UTtm/S1f5R9zo0fUA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gB2nDaCDsSqADjl0XJ1eAO4V0L1c/NnX8tyWbxoCkQTc5HJRYO+3NagAxp/Dka3ePQVqASh5dm7jVK3elwvCrwFzxe423cURpup70D2CA5qzYEAM4JaQix4NSu3BLAAF5SDkctO+ORHQhCztcoB1jQabEw0AL2EHnH/aIAVBnLkCtK6egQFqAIM+59YCat64tT4MBQXKdMAFnjkWARIMuDawixu9jKXBCQp0F3jY4+wl68MEAT5yWVPZc3MkHfAF2IDTpLr5ivIL5rTDefcB6QFSUnFhV57iAAGAwo5D6Qex/sz0I/XAHEgrnys61VuWgDeBgoLziH1DANAOoCRnzKAS84ISgARR6vH2Ph/kowPC0+FkL/Qmpy0B3KpYviX4cOYSoPYoTvsCnVTnzRsoIG2LiM9NYcR60gHOcjnDh0vwAMaqTUrO1fZ1Xrl5PxmwDOLdtcwF57i/yvcfAIeBKVtyVcygVvD9EKAD4DfJDdx0YF81AgIMjF5yvq4e3wKVAVj0uWpUwtqLDJDnPrcIqx8TAjiQsAHnWvueEDA8OOnaKVty8/1hPCpANuDIZvX5kUd9xhygQRqFnK4I/ZLvC5TikIvOEk1lBghxG51csSz72Nm3BwFPAgIeV1Cy1vwMU2vJhUl7q+bD/ciS9bqelw+nZQf43GXHCN66BUYI0lDYSxYeFys6kQ6XwCDaQi5GD1MQFA/PXmfxuGHnaXsmU6DqhVzyN++eBK6C+5rAhgVXAqpzdaBswhnG4XCH1w0k4BtwfEvYCryWA1Q7EImq2y510QF4W3JxXJ19A6OFzmJ3yfW/YgDkAaPlUPWj6oAmSFlpd7k+GYxX89lT8hRvim327OLy6vv3/wO2ElKC2GUAAA=="; \ No newline at end of file diff --git a/docs/classes/MiniSearch.MiniSearch.html b/docs/classes/MiniSearch.MiniSearch.html index 45cce209..feda2166 100644 --- a/docs/classes/MiniSearch.MiniSearch.html +++ b/docs/classes/MiniSearch.MiniSearch.html @@ -3,7 +3,7 @@
// The full set of options (here with their default value) is:
const miniSearch = new MiniSearch({
// idField: field that uniquely identifies a document
idField: 'id',
// extractField: function used to get the value of a field in a document.
// By default, it assumes the document is a flat object with field names as
// property keys and field values as string property values, but custom logic
// can be implemented by setting this option to a custom extractor function.
extractField: (document, fieldName) => document[fieldName],
// tokenize: function used to split fields into individual terms. By
// default, it is also used to tokenize search queries, unless a specific
// `tokenize` search option is supplied. When tokenizing an indexed field,
// the field name is passed as the second argument.
tokenize: (string, _fieldName) => string.split(SPACE_OR_PUNCTUATION),
// processTerm: function used to process each tokenized term before
// indexing. It can be used for stemming and normalization. Return a falsy
// value in order to discard a term. By default, it is also used to process
// search queries, unless a specific `processTerm` option is supplied as a
// search option. When processing a term from a indexed field, the field
// name is passed as the second argument.
processTerm: (term, _fieldName) => term.toLowerCase(),
// searchOptions: default search options, see the `search` method for
// details
searchOptions: undefined,
// fields: document fields to be indexed. Mandatory, but not set by default
fields: undefined
// storeFields: document fields to be stored and returned as part of the
// search results.
storeFields: []
})
-Static
Readonly
wildcardThe special wildcard symbol that can be passed to MiniSearch#search +
Static
Readonly
wildcardThe special wildcard symbol that can be passed to MiniSearch#search to match all documents
-The number of documents discarded since the most recent vacuuming
-A number between 0 and 1 giving an indication about the proportion of +
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
-Total number of documents available to search
+Is true
if a vacuuming operation is ongoing, false
otherwise
Number of terms in the index
+Adds all the given documents to the index asynchronously.
+Adds all the given documents to the index asynchronously.
Returns a promise that resolves (to undefined
) when the indexing is done.
This method is useful when index many documents, to avoid blocking the main
thread. The indexing is performed asynchronously and in chunks.
An array of documents to be indexed
Configuration options
Optional
chunkA promise resolving to undefined
when the indexing is done
Provide suggestions for the given search query
+Provide suggestions for the given search query
The result is a list of suggested modified search queries, derived from the given search query, each with a relevance score, sorted by descending score.
By default, it uses the same options used for search, except that by
@@ -78,7 +78,7 @@
default prefix search is performed on the last term in the query, and terms
are combined with 'AND'
.
A sorted array of suggestions sorted by relevance score.
-Discards the document with the given ID, so it won't appear in search results
+Discards the document with the given ID, so it won't appear in search results
It has the same visible effect of MiniSearch.remove (both cause the document to stop appearing in searches), but a different effect on the internal data structures:
@@ -118,7 +118,7 @@The ID of the document to be discarded
-Discards the documents with the given IDs, so they won't appear in search results
It is equivalent to calling MiniSearch#discard for all the given IDs, but with the optimization of triggering at most one automatic @@ -126,14 +126,14 @@
Note: to remove all documents from the index, it is faster and more convenient to call MiniSearch.removeAll with no argument, instead of passing all IDs to this method.
-Returns the stored fields (as configured in the storeFields
constructor
option) for the given document ID. Returns undefined
if the document is
not present in the index.
The document ID
-Removes the given document from the index.
The document to remove must NOT have changed between indexing and removal, otherwise the index will be corrupted.
This method requires passing the full document to be removed (not just the @@ -141,13 +141,13 @@ memory to be released. A convenient alternative is MiniSearch#discard, which needs only the document ID, and has the same visible effect, but delays cleaning up the index until the next vacuuming.
The document to be removed
-Removes all the given documents from the index. If called with no arguments, +
Removes all the given documents from the index. If called with no arguments, it removes all documents from the index.
Optional
documents: readonly T[]The documents to be removed. If this argument is omitted, all documents are removed. Note that, for removing all documents, it is more efficient to call this method with no arguments than to pass all documents.
-It replaces an existing document with the given updated version
It works by discarding the current version and adding the updated one, so it is functionally equivalent to calling MiniSearch#discard followed by MiniSearch#add. The ID of the updated document should @@ -157,7 +157,7 @@ memory to be released (see MiniSearch#discard).
The updated document to replace the old version with
-Search for documents matching the given search query.
+Search for documents matching the given search query.
The result is a list of scored document IDs matching the query, sorted by descending score, and each including data about which terms were matched and in which fields.
@@ -205,7 +205,7 @@ deeply nested queries, it provides a formalized expression tree API for external libraries that implement a parser for custom query languages.Search query
-Allows serialization of the index to JSON, to possibly store it and later +
Allows serialization of the index to JSON, to possibly store it and later deserialize it with MiniSearch.loadJSON.
Normally one does not directly call this method, but rather call the
standard JavaScript JSON.stringify()
passing the MiniSearch
@@ -215,7 +215,7 @@
// Serialize the index:
let miniSearch = new MiniSearch({ fields: ['title', 'text'] })
miniSearch.addAll(documents)
const json = JSON.stringify(miniSearch)
// Later, to deserialize it:
miniSearch = MiniSearch.loadJSON(json, { fields: ['title', 'text'] })
A plain-object serializable representation of the search index.
-Triggers a manual vacuuming, cleaning up references to discarded documents +
Triggers a manual vacuuming, cleaning up references to discarded documents from the inverted index
Vacuuming is only useful for applications that use the MiniSearch#discard or MiniSearch#replace methods.
By default, vacuuming is performed automatically when needed (controlled by @@ -246,13 +246,13 @@ times (enqueuing multiple ones would be useless).
Configuration options for the batch size and delay. See VacuumOptions.
-Static
getStatic
getReturns the default value of an option. It will throw an error if no option with the given name exists.
Name of the option
The default value of the given option
// Get default tokenizer
MiniSearch.getDefault('tokenize')
// Get default term processor
MiniSearch.getDefault('processTerm')
// Unknown options will throw an error
MiniSearch.getDefault('notExisting')
// => throws 'MiniSearch: unknown option "notExisting"'
-Static
loadJSONDeserializes a JSON index (serialized with JSON.stringify(miniSearch)
)
+
Static
loadJSONDeserializes a JSON index (serialized with JSON.stringify(miniSearch)
)
and instantiates a MiniSearch instance. It should be given the same options
originally used when serializing the index.
// If the index was serialized with:
let miniSearch = new MiniSearch({ fields: ['title', 'text'] })
miniSearch.addAll(documents)
const json = JSON.stringify(miniSearch)
// It can later be deserialized like this:
miniSearch = MiniSearch.loadJSON(json, { fields: ['title', 'text'] })
@@ -260,4 +260,4 @@
JSON-serialized index
configuration options, same as the constructor
An instance of MiniSearch deserialized from the given JSON.
-Generated using TypeDoc
The type of the documents being indexed.
Basic example:
-