question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lunr throws in Safari sometimes when calling the query method

See original GitHub issue

When calling the .query method with certain search terms in Safari, the following error is thrown:

TypeError: undefined is not an object (evaluating 'posting._index') 

The problem is here. Adding an check for posting solves the problem but I am almost certain this is a sign of a larger problem and this should be fixed upstream.

We found that removing wildcard option from all .term calls fixes the issue but search results suffer.

We are aware of this being reported here: https://github.com/olivernn/lunr.js/issues/276#issuecomment-308388470. We are working to create a reduced test case.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:37 (23 by maintainers)

github_iconTop GitHub Comments

3reactions
hftfcommented, Aug 26, 2019

With lunr 2.3.6 and the trimmer removed from the pipeline, I still encounter this issue sporadically.

The patch in #361 may have been insufficient or too localized. Maybe it should be guaranteed that an undefined posting doesn’t get past that line?

I see that the issue was already thoroughly investigated more than I can meaningfully contribute to. Anecdotally, it often happens when the term is empty (or stopwords), but I saw it happen with *m* several times too. I also use lunr-unicode-normalizer (monkey-patched for 2.x) for the rare document with Unicode text.

2reactions
olivernncommented, Sep 6, 2017

I’ve been doing some thinking about this and I think an approach forward is to improve the quality of the implementation of lunr.tokenizer. Its job is to turn some text into individual words or tokens. The fact that lunr.trimmer even exists suggests some inadequacy in the implementation of lunr.tokenzier. More generally, unicode is hard, and texts with non latin characters are not really well supported by the current approach.

I think an approach based on UAX#29 is probably more robust, though the implementation details are certainly more involved. I’m going to experiment with writing a tokeniser using the rules in the above document, I want to see how much better it is able to deal with these cases, as well as understanding what, if any, impact there is on performance (both speed and library size).

In the meantime I’m still interested in seeing if this bug can be isolated enough to show to the Safari developers, as its current behaviour is still weird to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSDoc: Class: Query - Lunr.js
A lunr.Query provides a programmatic way of defining queries to be performed against a lunr.Index. Prefer constructing a lunr.Query using the lunr.
Read more >
macOS Ventura is now available - Hacker News
The update is cool but the update process was not. -Update available, wanna install? Sure -OK don't mind me I'm gonna need a...
Read more >
javascript - Maximum call stack size exceeded error
It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you...
Read more >
Docs - Moment.js
toNow(); moment().toNow(Boolean);. A common way of displaying time is handled by moment#toNow . This is sometimes called timeago or relative ...
Read more >
Untitled
Elizabeth ivanova, Rahul speech in jodhpur, 2014 cooper river bridge run ... Sector verticalmente integrado, Throw stones synonym, Manger bien pendant la ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found