Add support for storing/retrieving field values
See original GitHub issueI’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:
- Created 9 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top 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 >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
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?
👍 I have an offline index step, so storing document metadata in the index would be beneficial.