olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.96k stars 548 forks source link

Recover the value of a field #94

Closed gaby44541 closed 10 years ago

gaby44541 commented 10 years ago

Hi,

Lunr is amazing but one thing that I don't understand. How to recover the value of a field (not only the ref and the score)? Let me explain: I create the index like this:

idx = lunr(function () { this.field('title', { boost: 1 }); this.field('body'); });

and I add document like this:

var doc = { "title": "a title", "body": document, "id": id, "name": name };

I would like recover the field "name" when I search a word. How can I do?

Thanks

jure commented 10 years ago

This is identical to: https://github.com/olivernn/lunr.js/issues/88

Lunr doesn't store the documents for you, you're supposed to take care of that.