Crash when searching "constructor"
See original GitHub issueHello! First, thanks for Minisearch, that’s a useful, well-designed lib.
I’ve found an interesting bug though: I use Minisearch for technical markdown documents, and some of them contain the word “constructor”. Minisearch crashes when I’m searching for any term that begins the word “constructor” (like “c”, “con”, “const”, “construct”…)
The code I’m using for the search:
const results = this.miniSearch.search(search, { prefix: true, boost: { title: 10 } })
Here’s the (webpack-mangled) outputted error:
TypeError: results[documentId].match[term].push is not a function
at eval (index.js?7f7f:1732)
at Array.forEach (<anonymous>)
at eval (index.js?7f7f:1714)
at Array.reduce (<anonymous>)
at termResults (index.js?7f7f:1703)
at MiniSearch.executeQuery (index.js?7f7f:1521)
at eval (index.js?7f7f:1295)
at Array.map (<anonymous>)
at MiniSearch.search (index.js?7f7f:1294)
at FilesNotesRepository._callee6$ (notes-files-repository.ts?700d:132)
index.js:1732 refers to results[documentId].match[term].push(field);
in this code:
Object.entries(ds).forEach(function (_ref15) {
var documentId = _ref15[0],
tf = _ref15[1];
var docBoost = boostDocument ? boostDocument(self._documentIds[documentId], term) : 1;
if (!docBoost) {
return;
}
var normalizedLength = self._fieldLength[documentId][fieldId] / self._averageFieldLength[fieldId];
results[documentId] = results[documentId] || {
score: 0,
match: {},
terms: []
};
results[documentId].terms.push(term);
results[documentId].match[term] = results[documentId].match[term] || [];
results[documentId].score += docBoost * score(tf, df, self._documentCount, normalizedLength, boost, editDistance);
results[documentId].match[term].push(field);
});
Thank you
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Crash in constructor with using virtual inheritance and ...
A quick examination of the assembly code generated by MSVC++ 2013 compiler shows that the delegated call from B::B(int) to B() is made ......
Read more >Crash of application if exception is thrown in constructor
I have experienced crash of application in case exception is thrown inside constructor of the class in release version of project with /O1...
Read more >Why is a C++ program crashing on constructor (C++ ... - Quora
Without seeing your code, it's impossible to say. What I'd do is the following: 1. Actually read the constructor code. Make sure that...
Read more >Default Constructor causing crash - c++ | Ars OpenForum
When you get a crash, you should learn to look at the callstack in the debugger. It will show you exactly where the...
Read more >Crashes in constructor C# - MSDN - Microsoft
I am just creating an application and on my first test things crash in a constructor. I am making a test case here....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You fixed it in less time than it took me to iteratively discover what was crashing 😄
Hi @scambier , thanks a lot for reporting this!
A solution for this issue is upcoming.