Closed pentode closed 10 years ago
I think storing documents in the manner you describe is probably out of scope for lunr. It seems to me that this kind of functionality is quite use-case specific and easy enough to do around lunr, if I understand the feature request properly.
I would have thought that you would have the actual documents being indexed available outside of lunr anyway. You could then retrieve these documents using the document refs that are being returned from the search.
Let me know if I have misunderstood what you're proposing, but I don't think this is something that I want to add to lunr.
I understand your points. I'm building an index (of 5000+ documents) server-side and syncing periodically to the mobile device. I'm also distributing 5000+ json files which contain the raw data for display purposes. I really like being able to show meaningful search result lists without loading the json data for each matched record. I can certainly serialize/deserialize the stored field data outside of lunr.
:+1: I have an offline index step, so storing document metadata in the index would be beneficial.
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?
@pentode I know it's ages ago - but by any chance can you throw up your modification as a gist or something?
This would be pretty useful. Maybe it could be set as an option?
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.,
and the result from lunr.Index.search(...) is
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...