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

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

问题描述

任何人都可以建议我在 Lucene 中获取每个文档的 Hits(没有出现次数)的最佳方法吗?..

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 中,使用 Document.getFields().
  3. 对于每个字段 f,使用 getTermFreqVector().
  4. 检查词向量和每个词的频率总和.
  5. 每个字段的词频总和将为您提供文档的词频向量.
  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 中获取每个文档的搜索词 Hits(出现次数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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