weixsong / elasticlunr.js

Based on lunr.js, but more flexible and customized.
http://elasticlunr.com
MIT License
2.02k stars 147 forks source link

remove a field after indexing #103

Open FranckFreiburger opened 5 years ago

FranckFreiburger commented 5 years ago

Hello, Is it possible to remove a field once it has been indexed ?

my document is:

- index
- content
- pageNum
- filename

my index config:

this.setRef('index');
this.addField('content');
this.saveDocument(true);

Since I have multiple big files, I want to reduce memory (and disk space) usage. My need is to find a filemane/pageNum from a word (in content), and I never need content after indexing.

I tried this (with success):

    for ( var id in idx.documentStore.docs )
        delete idx.documentStore.docs[id].content;

but I wondering if there is a better way to achieve this with the public API.