2

im trying to index a database table with Lucene 4. I index all fields of a table entry into a document as a TextField (1 document per table entry) and try to search over the directory afterward.

So my problem is, that i need all the field names that are in the directory to use a MultiFieldQuery.

QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_42, !FIELDS! , analyzer);

How do i get them? I could save them away while indexing, but it wouldn't be very performant to log them away with the index :/

Thank You Alex

4

1 回答 1

3

您可以从中获取字段名AtomicReader.getFieldInfos()

这将传回一个FieldInfos实例。循环FieldInfos.iterator(),并从中获取字段名称FieldInfo.name

不过,我不明白为什么提前将它们存储在某个地方会不高效。

于 2013-04-19T17:23:56.323 回答