在Lucene中获取每个文档的搜索词命中数(出现次数) [英] Get search word Hits ( number of occurences) per document in Lucene

查看:343
本文介绍了在Lucene中获取每个文档的搜索词命中数(出现次数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以建议我在Lucene中使每个文档的单词命中率最高的最佳方法吗?.

Can any one suggest me the best way to get Hits( no of occurrences ) of a word per document in Lucene?..

推荐答案

Lucene使用基于字段的索引,而不是基于文档的索引. 为了获得每个文档的字数:

Lucene uses a field-based, rather than document-based, index. In order to get term counts per document:

  1. 使用 IndexReader.document()和isDeleted().
  2. 在文档d中,使用
  1. Iterate over documents using IndexReader.document() and isDeleted().
  2. In document d, iterate over fields using Document.getFields().
  3. For each field f, get terms using getTermFreqVector().
  4. Go over the term vector and sum frequencies per terms.
  5. The sum of term frequencies per field will give you the document's term frequency vector.

这篇关于在Lucene中获取每个文档的搜索词命中数(出现次数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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