---
title: "Lucene的评分机制"
author: "mini_hu"
date: "2011-08-30T09:53:15Z"
tags: []
categories: ["开源软件"]
slug: "lucene"
draft: false
lastmod: "2011-08-30T09:53:15Z"
id: 1161081
url: "https://pwind.iteye.com/blog/1161081"
---

Searcher.explain(Query query, int doc)方法可以查看某个文档的得分的具体构成。 

Lucene中score是由 tf * idf * boost * lengthNorm计算得出的。 

tf：是查询的词在文档中出现的次数的平方根 
idf：表示反转文档频率，观察了一下所有的文档都一样，所以那就没什么用处，不会起什么决定作用。 
boost：激励因子，可以通过setBoost方法设置，需要说明的通过field和doc都可以设置，所设置的值会同时起作用 
lengthNorm：是由搜索的field的长度决定了，越长文档的分值越低。