Lucene 更改“;“目录”;要存储、标记、索引以突出显示的字段

Lucene 更改“;“目录”;要存储、标记、索引以突出显示的字段,lucene,pdfbox,Lucene,Pdfbox,这就是我如何从LucenePDF文档中获取详细信息的方式: doc=LucenePDFDocument.getDocument(文件); System.out.println(“字段列表:\n”+doc.getFields()); 这是输出: field list: [<stored<path:D:\Kuliah\rancangan document indexing\dir-pdf\dua.pdf>, stored<url:D:/Kuliah/rancangan d

这就是我如何从LucenePDF文档中获取详细信息的方式:

doc=LucenePDFDocument.getDocument(文件);
System.out.println(“字段列表:\n”+doc.getFields());
这是输出:

field list: 
[<stored<path:D:\Kuliah\rancangan document indexing\dir-pdf\dua.pdf>,
stored<url:D:/Kuliah/rancangan document indexing/dir-pdf/dua.pdf>,
stored,indexed,omitNorms,indexOptions=DOCS<modified:20170307220729>,
indexed,tokenized<uid:D Kuliah rancangan document indexing dir-pdf dua.pdf 20170307220729>, 
indexed,tokenized<contents:java.io.StringReader@4206a205>,
stored,indexed,tokenized<Author:Acer-2577>,
stored,indexed,tokenized<CreationDate:20150222074338>,
stored,indexed,tokenized<Creator:PDF24 Creator>,
stored,indexed,tokenized<ModificationDate:20150222074338>,
stored,indexed,tokenized<Producer:GPL Ghostscript 9.10>,
stored,indexed,tokenized<Title:Microsoft Word - Vol 10.1 bag ke 2a fix.doc>,
stored<summary:Jurnal Teknologi Informasi, Volume 10 Nomor 1, April ...>]
字段列表:

[是的,内容字段已编制索引但未存储,这意味着它将不会从搜索结果中返回,而是可搜索的,是的,这不适用于高亮显示

您需要修改LucenePDFDocument类以存储该字段。为此,只需向addTextField调用传递字符串,而不是读取器:

String contents=writer.getBuffer().toString();
addTextField(文档,“目录”,目录);

您可能还应该删除“summary”字段,因为如果存储完整内容,您将不需要它。

非常感谢您。现在我看到只需传递一个字符串即可生成field.Store.YES,这样我就可以突出显示匹配关键字