lucaong / minisearch

Tiny and powerful JavaScript full-text search engine for browser and Node
https://lucaong.github.io/minisearch/
MIT License
4.64k stars 133 forks source link

Add queryTerms to the search results #241

Closed lucaong closed 9 months ago

lucaong commented 9 months ago

The queryTerms field is useful in order to know which query terms matched in the search result. When performing an exact search, terms and queryTerms are identical. In case of prefix or fuzzy match though, they can be different.

For example, if one searches for "moto" using prefix search, and a document matches because it contains the word "motorcycle", then for that result the terms array will include "motorcycle", while the queryTerms array will include "moto".

Also see https://github.com/lucaong/minisearch/issues/240 for a use case.