weixsong / elasticlunr.js

Based on lunr.js, but more flexible and customized.
http://elasticlunr.com
MIT License
2.03k stars 148 forks source link

word "about" is never matched #101

Closed pdeona closed 5 years ago

pdeona commented 5 years ago

https://codepen.io/pdeona/pen/VgVLQg?editors=0010

Using this lib via the gatsby plugin and noticed the results weren't quite what was expected. i created this pen using only elasticlunr and my exact config, with some test data and confirmed - the term About is never matched, for any search terms i could come up with. I would imagine this effects quite a few people but didn't see an existing issue.

edit: stopWordFilter is disabled.

srenauld commented 5 years ago

This was not an issue with the library itself, but with your usage of it. this codepen fork illustrates this.

Since elasticlunr does not keep the entire document anywhere beyond the fields you've told it to retain, the pipeline needs to run on every document insertion. In your codepen, you removed the stop word filter from the pipeline after the documents were added. In addition to this, but this is minor, this == index while in that closure.

I made the following changes to your codepen to get it to work:

Let me know if this helped!