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

Error in some search queries #40

Closed
tinganho opened this issue Jul 9, 2013 · 5 comments
Closed

Error in some search queries #40

tinganho opened this issue Jul 9, 2013 · 5 comments

Comments

@tinganho
Copy link

tinganho commented Jul 9, 2013

I got this error on some certain search queries

TypeError: Cannot read property 'tf' of undefined at lunr.Index.documentVector (/usr/local/lib/node_modules/grunt-translate/node_modules/lunr/lunr.js:1104:53) at lunr.Index.search (/usr/local/lib/node_modules/grunt-translate/node_modules/lunr/lunr.js:1076:61) at Array.map (native) at lunr.SortedSet.map (/usr/local/lib/node_modules/grunt-translate/node_modules/lunr/lunr.js:574:24) at lunr.Index.search (/usr/local/lib/node_modules/grunt-translate/node_modules/lunr/lunr.js:1075:6) at Search.query (/usr/local/lib/node_modules/grunt-translate/src/modules/search.js:93:24) at module.exports (/usr/local/lib/node_modules/grunt-translate/app/modules/search/searchApi.js:9:21) at callbacks (/usr/local/lib/node_modules/grunt-translate/node_modules/express/lib/router/index.js:161:37) at param (/usr/local/lib/node_modules/grunt-translate/node_modules/express/lib/router/index.js:135:11) at pass (/usr/local/lib/node_modules/grunt-translate/node_modules/express/lib/router/index.js:142:5)

@olivernn
Copy link
Owner

olivernn commented Jul 9, 2013

Thanks for reporting this error, please let me know what version of lunr you are using (and what version of node). It'd be really useful if you could provide a cut down version of your index and a query that causes the error too.

@severinh
Copy link

severinh commented Sep 5, 2013

lunr.js crashed on exactly the same line of code in my case because my German stop word filter did not filter the empty string. Apparently, the document store contained the empty string token, while the token store did not, leading to the error. Of course, there might be a different cause in tinganho's case.

Either way, I might try to find the source of the empty string bug and provide a fix and corresponding test case.

@tinganho
Copy link
Author

@severinh and @olivernn I removed this line after this.index.pipeline.remove(lunr.stopWordFilter); creating the index caused this problem. I installed it recently with bower@0.4.3

@shredding
Copy link

Adding

this.pipeline.add(function (token) {
    if (token.length > 0) return token;
})

fixed it for me.

@olivernn
Copy link
Owner

Wow, this is an old issue! I've pushed changes now in 0.6.0 that should solve this issue, let me know if you still have issues with the latest version.

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

4 participants