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.

Matching results disappear when expending the term

See original GitHub issue

Hi Oliver,

I am working with lunr since a couple of week (which I have to say is awesome in term of easy to use, and features). I am having a strange behavior who seems to be similar to something already described in this issue #68

I have entries some containing phone, others containing iphone. If I search for phon, both phone and iphone entries are returned. If I search for phone, only phone entries are returned.

I am using leading and trailing wildcard on term :

q.term(term, {
    boost: 100
})

q.term(term, {
     boost: 10,
     usePipeline: false,
     wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING
})

I tried by adding only with leading wildcard, but results are the same. It can be easily reproduce with this code :

const lunr = require('lunr')
const data = [{name: 'phone'}, {name: 'iphone'}]
const index = lunr(function () {
  this.ref('name')
  this.field('name')
  data.forEach(item => this.add(item))
})

index.search('phone')
// [ { ref: 'phone', score: 1, matchData: { metadata: [Object] } } ]
index.search('iphone')
// [ { ref: 'iphone', score: 1, matchData: { metadata: [Object] } } ]
index.search('*phone')
// [ { ref: 'phone', score: 1, matchData: { metadata: [Object] } } ]
index.search('*phon')
// [ { ref: 'iphone', score: 1, matchData: { metadata: [Object] } } ]

Am I missing something, or is this a bug ? If it’s one, how can I help to solve it ?

Thanks a lot.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
olivernncommented, Sep 7, 2017

@myalgo @mike1808 the test I just added.

1reaction
olivernncommented, Sep 7, 2017

@gsavin yeah, stemming is a bit of a black box, I didn’t write the current stemmer, so its even more of a black box. I did think about re-implementing it, if nothing else then to understand the rules a bit more, but time is always in short supply!

@mike1808 regarding the behaviour of the wildcard, I think that is a bug, or at least incorrectly implemented. I took inspiration for the syntax from Lucene and its * matches 0 or more, where it looks like Lunr implements it as 1 or more. I’ll take a look at what would be involved in fixing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Power Query - Row disappear after expand column
Solved: Hello, I have encountered a strange thing when I expand merged table column. I use JoinKind.LeftOuter to merge queries - that should...
Read more >
INQUIZITIVE; Chapter 28 Flashcards - Quizlet
The Great Recession was given that name because a recession is a brief contraction in an economy that goes away quickly. This Great...
Read more >
Set table cells to expand with contents in Word
Word usually wraps text in a table cell automatically. However, if your rows are set to an exact height, the cells won't expand...
Read more >
Frequently Asked Questions — COLMAP 3.8 documentation
Try decreasing the option --SiftMatching.max_num_matches until the error disappears. Note that this might lead to inferior feature matching results, ...
Read more >
Create advanced animations with smart animate
With smart animate matching layers, Figma will move or slide in layers based on their hierarchy, which can cause some confusing or unexpected...
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