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

TypeError: Cannot convert undefined or null to object #360

Closed
brandon-bethke-timu opened this issue Jul 19, 2018 · 3 comments
Closed

TypeError: Cannot convert undefined or null to object #360

brandon-bethke-timu opened this issue Jul 19, 2018 · 3 comments

Comments

@brandon-bethke-timu
Copy link

The following code will throw an exception: TypeError: Cannot convert undefined or null to object

const lunr = require("lunr");
let lunarbuilder;
lunr(builder => {
    lunrbuilder = builder;
    builder.field('name');
    builder.field('description');
    builder.ref('id');
});

lunrbuilder.add({
    name: 'myname',
    description: 'mydescription',
    type: 'core:test',
    key: '1',
    id: 1,
    url: '/api/graph/core:test/1',
    createdAt: '2018-07-19T20:33:18.964Z',
    archived: false
});

lunrbuilder.add({
    name: 'myname2',
    description: 'mydescription',
    type: 'core:test',
    key: '2',
    id: 2,
    url: '/api/graph/core:test/2',
    createdAt: '2018-07-19T20:33:18.968Z',
    archived: false
});

let search = lunrbuilder.build();
search.search("+name:myname +description:value");
@olivernn
Copy link
Owner

Thanks for reporting, I was able to reproduce this issue. It looks like it is triggered when the search contains two required terms each scoped by a field but one that matches nothing.

I've tracked the bug down to the way that lunr.Set.complete and lunr.Set.empty are handled in lunr.Set#union and lunr.Set#intersect. I'll put together a bug fix and a new release in the next few days.

@asinakdeniz
Copy link

Hi,
We have faced with the same problem so kindly request you to this fix this bug as soon as possible. We will be waiting a new release impatiently. Many thanks...

@olivernn
Copy link
Owner

I have just published 2.3.1 which contains a fix for this issue.

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

3 participants