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.

Add support for storing/retrieving field values

See original GitHub issue

I’ve made a (successful!) first pass at adding support for storing/retrieving field values. I added a fieldStore property to lunr.Index and populate that when the stored property of the field is true, e.g.,

var index = lunr(function () {
  this.ref('id');
  this.field('title',{boost:20, store: true});
  this.field('subtitle',{boost:10, store: true});
  this.field('bio',{boost:5});
  this.field('toc',{boost:5});
  this.field('desc',{boost:4});
});

and the result from lunr.Index.search(…) is

[ { ref: '4371',
    score: 0.02380936053390949,
    fields: 
     { title: '...',
       subtitle: '...' } },
  { ref: '395',
    score: 0.002723523438116153,
    fields: { title: '...' } } ]

To keep the serialize/deserialize functionality, I had to tweak the lunr.Store.load method so it isn’t directly coupled to lunr.SortedSet, because the value of lunr.Store entries is now an object instead of a SortedSet. Maybe I shouldn’t have used lunr.Store for this new fieldStore property, though?

If this is a feature that you’d like to have added, I’ll clean up my work and make sure all tests are passing…

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
hoogwcommented, Sep 18, 2019

In 2019 I have same need !!!

the return result only show ref id. I actually want the real full json item associate with that ref id!!!

Otherwise, how I am going to use the returned ref id to retrieve the real full json element?

1reaction
kevinastonecommented, Oct 16, 2014

👍 I have an offline index step, so storing document metadata in the index would be beneficial.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add a lookup or values list field to an Access web app
Use a lookup field to find ("look up") values in one table that you can use in another table. A lookup field can...
Read more >
getFieldValue(record, field) - Salesforce Developers
To get the value of a record's field, you can use the getRecord wire adapter, which returns the property record.data.fields.fieldName.value . However, you...
Read more >
Retrieve selected fields from a search | Elasticsearch Guide [8.5]
Use the docvalue_fields parameter to get values for selected fields. This can be a good choice when returning a fairly small number of...
Read more >
Get and Set Field Values using FormContext and JavaScript ...
In this post, we will look at how to get and set field values using FormContext and JavaScript. Let's say we want to...
Read more >
How to get a list of specific fields values from objects stored in ...
Fortunately, you can do this using Java 8 - Streams. Assume you have an entity named YourEntity public class YourEntity { private String...
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