【问题标题】:search problem in lucene 3.0.2lucene 3.0.2 中的搜索问题
【发布时间】:2010-12-15 06:02:01
【问题描述】:

压缩字段值后,我已对该字段执行存储和索引 但是当我尝试搜索值时,我得到了命中但没有得到值。我怎样才能获得价值呢?

/* 这是我的索引代码 */

文档 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));

/* 搜索代码 */

查询查询 = 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 
}

【问题讨论】:

    标签: lucene


    【解决方案1】:

    使用doc.getBinaryValue() 代替doc.get()

    【讨论】:

      猜你喜欢
      • 2016-03-05
      • 2013-05-25
      • 2015-04-12
      • 2015-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-25
      相关资源
      最近更新 更多