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 @@

Type Parameters

Hierarchy

Constructors

Hierarchy

  • MiniSearch

Constructors

Properties

Accessors

dirtCount dirtFactor @@ -33,29 +33,29 @@

Options and defaults:

// 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: []
})
-

Returns MiniSearch<T>

Properties

wildcard: typeof wildcard = ...

The special wildcard symbol that can be passed to MiniSearch#search +

Returns MiniSearch<T>

Properties

wildcard: typeof wildcard = ...

The special wildcard symbol that can be passed to MiniSearch#search to match all documents

-

Accessors

Accessors

Methods

Methods

Returns void

Returns void

Returns Suggestion[]

A sorted array of suggestions sorted by relevance score.

-

Parameters

  • id: any

    The ID of the document to be discarded

    -

Returns void

Returns void

Returns undefined | Record<string, unknown>

Returns boolean

Returns void

Returns void

Returns void

Returns SearchResult[]

Returns Promise<void>

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/classes/SearchableMap_SearchableMap.SearchableMap.html b/docs/classes/SearchableMap_SearchableMap.SearchableMap.html index c3c52cb2..d7e4a6c9 100644 --- a/docs/classes/SearchableMap_SearchableMap.SearchableMap.html +++ b/docs/classes/SearchableMap_SearchableMap.SearchableMap.html @@ -8,7 +8,7 @@ exported by the minisearch package and can be imported (or required) as minisearch/SearchableMap.

Type Parameters

Hierarchy

Constructors

Hierarchy

  • SearchableMap

Constructors

Accessors

Methods

[iterator] atPrefix @@ -31,30 +31,30 @@ object, check SearchableMap.from and SearchableMap.fromObject.

The constructor arguments are for internal use, when creating derived mutable views of a map at a prefix.

-

Type Parameters

  • T = any

Parameters

  • tree: RadixTree<T> = ...
  • prefix: string = ''

Returns SearchableMap<T>

Accessors

Methods

Accessors

Methods

  • Creates and returns a mutable view of this SearchableMap, containing only entries that share the given prefix.

    Usage:

    let map = new SearchableMap()
    map.set("unicorn", 1)
    map.set("universe", 2)
    map.set("university", 3)
    map.set("unique", 4)
    map.set("hello", 5)

    let uni = map.atPrefix("uni")
    uni.get("unique") // => 4
    uni.get("unicorn") // => 1
    uni.get("hello") // => undefined

    let univer = map.atPrefix("univer")
    univer.get("unique") // => undefined
    univer.get("universe") // => 2
    univer.get("university") // => 3

    Parameters

    • prefix: string

      The prefix

    Returns SearchableMap<T>

    A SearchableMap representing a mutable view of the original Map at the given prefix

    -
  • Returns TreeIterator<T, "ENTRIES">

    An iterator iterating through [key, value] entries.

    +
  • Fetches the value of the given key. If the value does not exist, calls the given function to create a new value, which is inserted at the given key and subsequently returned.

    Example:

    const map = searchableMap.fetch('somekey', () => new Map())
    map.set('foo', 'bar')

    Parameters

    • key: string

      The key to update

    • initial: (() => T)
        • (): T
        • Returns T

    Returns T

    The existing or new value at the given key

    -
  • Returns a Map of all the entries that have a key within the given edit distance from the search key. The keys of the returned Map are the matching keys, while the values are two-element arrays where the first element is the value associated to the key, and the second is the edit distance of the @@ -64,20 +64,20 @@

    Parameters

    • key: string

      The search key

    • maxEditDistance: number

      The maximum edit distance (Levenshtein)

    Returns FuzzyResults<T>

    A Map of the matching keys to their value and edit distance

    -
  • Updates the value at the given key using the provided function. The function is called with the current value at the key, and its return value is used as the new value to be set.

    Example:

    // Increment the current value by one
    searchableMap.update('somekey', (currentValue) => currentValue == null ? 0 : currentValue + 1) @@ -88,12 +88,12 @@

    Parameters

    • key: string

      The key to update

    • fn: ((value) => T)

      The function used to compute the new value from the current one

        • (value): T
        • Parameters

          • value: undefined | T

          Returns T

    Returns SearchableMap<T>

    The SearchableMap itself, to allow chaining

    -

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 0a18233f..c7570859 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3,7 +3,7 @@ Minzipped Size npm npm downloads -types

+types

MiniSearch is a tiny but powerful in-memory fulltext search engine written in JavaScript. It is respectful of resources, and it can comfortably run both in Node and in the browser.

@@ -53,7 +53,7 @@

Alternatively, if you prefer to use a <script> tag, you can require MiniSearch from a CDN:

-
<script src="https://cdn.jsdelivr.net/npm/minisearch@6.2.0/dist/umd/index.min.js"></script>
+
<script src="https://cdn.jsdelivr.net/npm/minisearch@6.3.0/dist/umd/index.min.js"></script>
 

In this case, MiniSearch will appear as a global variable in your project.

Finally, if you want to manually build the library, clone the repository and run @@ -112,7 +112,7 @@

The default term processor can be obtained by calling MiniSearch.getDefault('processTerm').

-

API Documentation

Refer to the API +

API Documentation

Refer to the API documentation for details about configuration options and methods.

Browser compatibility

MiniSearch natively supports all modern browsers implementing JavaScript diff --git a/docs/modules/MiniSearch.html b/docs/modules/MiniSearch.html index 1a216431..30a18382 100644 --- a/docs/modules/MiniSearch.html +++ b/docs/modules/MiniSearch.html @@ -1,4 +1,4 @@ -MiniSearch | MiniSearch

Module MiniSearch

Index

Classes

MiniSearch +MiniSearch | MiniSearch

Module MiniSearch

Index

Classes

Type Aliases

AutoVacuumOptions BM25Params MatchInfo diff --git a/docs/modules/SearchableMap_SearchableMap.html b/docs/modules/SearchableMap_SearchableMap.html index c2a633f4..3bbb7c77 100644 --- a/docs/modules/SearchableMap_SearchableMap.html +++ b/docs/modules/SearchableMap_SearchableMap.html @@ -1,2 +1,2 @@ -SearchableMap/SearchableMap | MiniSearch

Module SearchableMap/SearchableMap

Index

Classes

SearchableMap +SearchableMap/SearchableMap | MiniSearch

Module SearchableMap/SearchableMap

Index

Classes

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/types/MiniSearch.AutoVacuumOptions.html b/docs/types/MiniSearch.AutoVacuumOptions.html index 7ad90dc1..eefb046b 100644 --- a/docs/types/MiniSearch.AutoVacuumOptions.html +++ b/docs/types/MiniSearch.AutoVacuumOptions.html @@ -4,4 +4,4 @@ minDirtFactor thresholds defined by this configuration. See VacuumConditions for details on these.

Also, batchSize and batchWait can be specified, controlling batching behavior (see VacuumOptions).

-

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/types/MiniSearch.BM25Params.html b/docs/types/MiniSearch.BM25Params.html index 22e5653b..d8e817c7 100644 --- a/docs/types/MiniSearch.BM25Params.html +++ b/docs/types/MiniSearch.BM25Params.html @@ -21,4 +21,4 @@ difference in score between documents with higher and lower term frequencies. Setting this to 0 or a negative value is invalid. Defaults to 1.2

-

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/types/MiniSearch.MatchInfo.html b/docs/types/MiniSearch.MatchInfo.html index d0f80451..86214001 100644 --- a/docs/types/MiniSearch.MatchInfo.html +++ b/docs/types/MiniSearch.MatchInfo.html @@ -1,4 +1,4 @@ MatchInfo | MiniSearch

Type alias MatchInfo

MatchInfo: {
    [term: string]: string[];
}

Match information for a search result. It is a key-value object where keys are terms that matched, and values are the list of fields that the term was found in.

-

Type declaration

  • [term: string]: string[]

Generated using TypeDoc

\ No newline at end of file +

Type declaration

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/types/MiniSearch.Options.html b/docs/types/MiniSearch.Options.html index 5e7b6263..f99e80e6 100644 --- a/docs/types/MiniSearch.Options.html +++ b/docs/types/MiniSearch.Options.html @@ -30,4 +30,4 @@

Parameters

Returns string | string[] | null | undefined | false

  • Optional searchOptions?: SearchOptions

    Default search options (see the SearchOptions type and the MiniSearch#search method for details)

  • Optional storeFields?: string[]

    Names of fields to store, so that search results would include them. By default none, so results would only contain the id field.

    -
  • Optional tokenize?: ((text, fieldName?) => string[])
  • Generated using TypeDoc

    \ No newline at end of file +
  • Optional tokenize?: ((text, fieldName?) => string[])
  • Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/types/MiniSearch.Query.html b/docs/types/MiniSearch.Query.html index 7bf8867f..e6bce26a 100644 --- a/docs/types/MiniSearch.Query.html +++ b/docs/types/MiniSearch.Query.html @@ -1,3 +1,3 @@ Query | MiniSearch
    Query: QueryCombination | string | Wildcard

    Search query expression, either a query string or an expression tree combining several queries with a combination of AND or OR.

    -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/types/MiniSearch.QueryCombination.html b/docs/types/MiniSearch.QueryCombination.html index 77a7be81..1a9bea73 100644 --- a/docs/types/MiniSearch.QueryCombination.html +++ b/docs/types/MiniSearch.QueryCombination.html @@ -1 +1 @@ -QueryCombination | MiniSearch

    Type alias QueryCombination

    QueryCombination: SearchOptions & {
        queries: Query[];
    }

    Type declaration

    Generated using TypeDoc

    \ No newline at end of file +QueryCombination | MiniSearch

    Type alias QueryCombination

    QueryCombination: SearchOptions & {
        queries: Query[];
    }

    Type declaration

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/types/MiniSearch.SearchOptions.html b/docs/types/MiniSearch.SearchOptions.html index 042f142f..0547b8bc 100644 --- a/docs/types/MiniSearch.SearchOptions.html +++ b/docs/types/MiniSearch.SearchOptions.html @@ -54,4 +54,4 @@ for indexing is used also for search.

    Parameters

    Returns string[]

  • Optional weights?: {
        fuzzy: number;
        prefix: number;
    }

    Relative weights to assign to prefix search results and fuzzy search results. Exact matches are assigned a weight of 1.

    -
  • Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/types/MiniSearch.SearchResult.html b/docs/types/MiniSearch.SearchResult.html index 38418b31..b95e662b 100644 --- a/docs/types/MiniSearch.SearchResult.html +++ b/docs/types/MiniSearch.SearchResult.html @@ -1,9 +1,12 @@ -SearchResult | MiniSearch

    Type alias SearchResult

    SearchResult: {
        id: any;
        match: MatchInfo;
        score: number;
        terms: string[];
        [key: string]: any;
    }

    Type of the search results. Each search result indicates the document ID, the +SearchResult | MiniSearch

    Type alias SearchResult

    SearchResult: {
        id: any;
        match: MatchInfo;
        queryTerms: string[];
        score: number;
        terms: string[];
        [key: string]: any;
    }

    Type of the search results. Each search result indicates the document ID, the terms that matched, the match information, the score, and all the stored fields.

    Type declaration

    • [key: string]: any

      Stored fields

    • id: any

      The document ID

    • match: MatchInfo

      Match information, see MatchInfo

      +
    • queryTerms: string[]

      List of query terms that matched. For example, if a prefix search for +"moto" matches "motorcycle", queryTerms will contain "moto".

    • score: number

      Score of the search results

      -
    • terms: string[]

      List of terms that matched

      -

    Generated using TypeDoc

    \ No newline at end of file +
  • terms: string[]

    List of document terms that matched. For example, if a prefix search for +"moto" matches "motorcycle", terms will contain "motorcycle".

    +
  • Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/types/MiniSearch.Suggestion.html b/docs/types/MiniSearch.Suggestion.html index cf6ddbdf..10f28a8f 100644 --- a/docs/types/MiniSearch.Suggestion.html +++ b/docs/types/MiniSearch.Suggestion.html @@ -2,4 +2,4 @@

    Type declaration

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/types/MiniSearch.VacuumConditions.html b/docs/types/MiniSearch.VacuumConditions.html index 1e01cd85..df867ad1 100644 --- a/docs/types/MiniSearch.VacuumConditions.html +++ b/docs/types/MiniSearch.VacuumConditions.html @@ -4,4 +4,4 @@ under which auto vacuum is not triggered. It defaults to 20.

  • Optional minDirtFactor?: number

    Minimum dirtFactor (proportion of discarded documents over the total) under which auto vacuum is not triggered. It defaults to 0.1.

    -
  • Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/types/MiniSearch.VacuumOptions.html b/docs/types/MiniSearch.VacuumOptions.html index fba3fda2..b596452c 100644 --- a/docs/types/MiniSearch.VacuumOptions.html +++ b/docs/types/MiniSearch.VacuumOptions.html @@ -8,4 +8,4 @@

    Type declaration

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/types/MiniSearch.Wildcard.html b/docs/types/MiniSearch.Wildcard.html index 26c145d1..8e061015 100644 --- a/docs/types/MiniSearch.Wildcard.html +++ b/docs/types/MiniSearch.Wildcard.html @@ -1,2 +1,2 @@ Wildcard | MiniSearch

    Type alias Wildcard

    Wildcard: typeof wildcard

    Wildcard query, used to match all terms

    -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file