Lunr search
: shell
: lunr-search
: search-engine
: /modules/core/search/services/lunr-search.js
: https://github.com/DecentCMS/DecentCMS/blob/master/modules/core/search/services/lunr-search.js
LunrIndex
An in-memory search engine implementation with file storage suitable for small sites.
Kind: global class
new LunrIndex(scope, [idFilter], map, name, fields)
Constructs a Lunr index from the provided id filter and map
Param | Type | Description |
---|---|---|
scope | object |
The scope. |
[idFilter] | RegExp |
A regular expression that validates content item ids before they are read and indexed. |
map | function |
The map function takes a content item and returns an index entry, or null. An index entry should have an id property. The index will automatically add an id property set to be the id of the item that was used to build the index entries if none is provided. |
name | string |
A name for the index. |
fields | Array.<string> |
The list of fields to index. If no value is provided, title and body are used. |
lunrIndex.build()
Builds or re-builds the index. Having called that method does not mean that the index will be filled on the next instruction, as this works asynchronously.
Kind: instance method of LunrIndex
lunrIndex.search(options, done)
Searches the index.
Kind: instance method of LunrIndex
Param | Type | Description |
---|---|---|
options | object |
The options object. |
options.query | string |
The query string. |
[options.where] | function |
A condition on the index entries. |
[options.start] | Number |
The index of the first entry to be returned that evaluates true from the where clause. |
[options.count] | Number |
The number of entries to return. Omit if an unlimited number of items can be returned. |
done | function |
The callback, that takes the array of results. The array of results has a totalCount property giving the total unpaginated count. |