lucene 遍历所有term
Please read full article from lucene 遍历所有term
Directory indexDirectory = FSDirectory.open(
new
File(
"/home/ranger/index/1"
));
IndexReader indexReader = DirectoryReader.open(indexDirectory);
Fields fields = MultiFields.getFields(indexReader );
Iterator<String> fieldsIterator = fields.iterator();
while
(fieldsIterator.hasNext()){
String field = fieldsIterator.next();
Terms terms = fields.terms(field);
TermsEnum termsEnums = terms.iterator(
null
);
BytesRef byteRef =
null
;
System.out.println(
"field : "
+ field);
while
((byteRef = termsEnums.next()) !=
null
) {
String term =
new
String(byteRef.bytes, byteRef.offset, byteRef.length);
System.out.println(
"term is : "
+ term);
}
}
No comments:
Post a Comment