使用Java从Lucene索引获取所有存储的字段 [英] Get all stored fields from lucene index using java

查看:45
本文介绍了使用Java从Lucene索引获取所有存储的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示存储在Lucene索引中的单词,以便用户可以选择单词并获取相应的文档.我是Lucene的新手.感谢您的帮助.

I want to show the words stored in Lucene index so that user can select the word and get corresponding documents. I am new to Lucene. Any help is appreciated.

推荐答案

问题是Lucene中没有神奇的getAllStoredFields()函数.Lucene将字段存储在文档中,然后将其存储在索引中,索引中的每个文档都可以具有包含存储字段的不同字段.您需要检索一个特定的文档喜欢:

The issue is that there is no magic getAllStoredFields() function in Lucene. Lucene stores fields in documents which are then stored in an index, every document in the index can have different fields containing stored fields. You need to retrieve one specific document Like:

Document doc = indexReader.document(docNum);并调用doc.getFields().然后遍历它们并检查field.isStored()

Document doc = indexReader.document(docNum); and call doc.getFields(). Then iterate over them and checking field.isStored()

这篇关于使用Java从Lucene索引获取所有存储的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆