Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Won't work with some words #201

Closed
pgn-vole opened this issue Feb 12, 2016 · 1 comment
Closed

Won't work with some words #201

pgn-vole opened this issue Feb 12, 2016 · 1 comment

Comments

@pgn-vole
Copy link

It seems that some words cannot get matched.

Here is how to reproduce:

 var index = lunr(function () {
    this.field('title', {boost: 10})
    this.ref('id')
  })

index.add({
    id: 1,
    title: 'Just What'
  })

index.search('Just') // []  

By replacing "Just" with an other word it seems to work fine.

@olivernn
Copy link
Owner

Both of those words are considered stop words by lunr and are filtered out. This means they don't appear in the index and are stripped from searches.

Stop words are removed because they are very common and usually contribute little to differentiating one document from another, this helps keep the index size down and improves query performance.

If you really need to search for words that are stop words you can remove the stop word filter like so:

index.pipeline.remove(lunr.stopWordFilter)

Alternatively you can generate your own stop word filter that is more specific to your use case:

var myStopWordFilter = lunr.generateStopWordFilter(['your', 'stop', 'words', 'here'])
index.pipelline.before(lunr.stopWordFilter, myStopWordFilter)
index.pipeline.remove(lunr.stopWordFilter)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants