的elasticlunr.js
搜索配置如下返回文檔對象,Elasticlunr搜索基於所述索引
var index = elasticlunr(function() {
this.addField('title');
this.addField('body');
this.setRef('id');
});
var doc1 = {
"id": '1',
"title": "Oracle released its latest database Oracle 12g beta",
"body": "Yestaday Oracle has released its new database Oracle 12g, this would make more money for this company and lead to a nice profit report of annual year."
}
var doc2 = {
"id": '2',
"title": "Oracle released its profit report of 2015",
"body": "As expected, Oracle released its profit report of 2015, during the good sales of database and hardware, Oracle's profit of 2015 reached 12.5 Billion."
}
index.addDoc(doc1);
index.addDoc(doc2);
let result = index.search("beta");
它返回,
[{ 「REF」: 「1」, 「得分」: 0.3779644730092272}]
這個elasticlunr document表示它存儲索引文件。
那麼我怎樣才能從該特定索引獲取存儲文件?
我期待將我的原始文檔作爲搜索結果嗎? 即。
[{
"id": '1',
"title": "Oracle released its latest database Oracle 12g beta",
"body": "Yestaday Oracle has released its new database Oracle 12g, this would make more money for this company and lead to a nice profit report of annual year."
}]
是..我這樣做有點早..問題是我需要更新我的索引和數組對象,以及。這將很難管理。從存儲的角度來看,我需要存儲'lunr索引對象'和'整個對象在數組中' –