开发者

search problem in lucene 3.0.2

a开发者_如何转开发fter compressing field value i have perform storing and indexing of that field but when i try to search the value, i got the hits but not the value. how can i get the value also?

/* Here is my code for indexing */

Document absDoc = new Document(); valuesbyte = CompressionTools.compress(valueForCompress.getBytes());

    absDoc.add(new Field("Abstract", valuesbyte, Field.Store.YES));
    absDoc.add(new Field("Abstract", valueForCompress, Field.Store.NO,  
               Field.Index.ANALYZED, Field.TermVector.NO));

/* Code for searching */

Query query = parser.parse(searchStr); TopDocs hits = is.search(query, 10);

System.out.println("Hits = " + hits.scoreDocs.length);  // It's displaying all hits
Document doc = new Document(); 

for(int i=0;i<hits.scoreDocs.length;i++) {
    ScoreDoc scoreDoc = hits.scoreDocs[i]; 
    doc = is.doc(scoreDoc.doc);
    System.out.println(doc.get(fieldName));   // Here i got null value 
}


Use doc.getBinaryValue() instead of doc.get().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜