- 浏览: 284755 次
- 性别:
- 来自: 湖南岳阳
-
最新评论
-
ternus:
兄弟,我用boboBrowse 也遇到了排序的问题,上线了讨论 ...
lucene 分组 bobo-Browse 排序的问题 -
luli0822:
Awesome bookmarks of those guru ...
流行的jQuery信息提示插件(jQuery Tooltip Plugin) -
shenbai:
如果你要在前台运行,你应该run得是ElasticSearch ...
ElasticSearch 源码分析 环境入门 -
cl1154781231:
<s:peroperty value="#at ...
关于Struts2中标签的一些心得 -
RonQi:
转载的吗?http://blog.csdn.net/stray ...
利用bobo-browse 实现lucene的分组统计功能
关于Lucene得分的计算。
在IndexSearcher类中有一个管理Lucene得分情况的方法,如下所示:
public Explanation explain(Weight weight, int doc) throws IOException {
return weight.explain(reader, doc);
}
返回的这个Explanation的实例解释了Lucene中Document的得分情况。我们可以测试一下,直观地感觉一下到底这个Explanation的实例都记录了一个Document的哪些信息。
写一个测试类,如下所示:
package org.shirdrn.lucene.learn;
import java.io.IOException;
import java.util.Date;
import net.teamhot.lucene.ThesaurusAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.LockObtainFailedException;
public class AboutLuceneScore {
private String path = "E:\\Lucene\\index";
public void createIndex(){
IndexWriter writer;
try {
writer = new IndexWriter(path,new ThesaurusAnalyzer(),true);
Field fieldA = new Field("contents","一人",Field.Store.YES,Field.Index.TOKENIZED);
Document docA = new Document();
docA.add(fieldA);
Field fieldB = new Field("contents","一人 之交 一人之交",Field.Store.YES,Field.Index.TOKENIZED);
Document docB = new Document();
docB.add(fieldB);
Field fieldC = new Field("contents","一人 之下 一人之下",Field.Store.YES,Field.Index.TOKENIZED);
Document docC = new Document();
docC.add(fieldC);
Field fieldD = new Field("contents","一人 做事 一人当 一人做事一人当",Field.Store.YES,Field.Index.TOKENIZED);
Document docD = new Document();
docD.add(fieldD);
Field fieldE = new Field("contents","一人 做事 一人當 一人做事一人當",Field.Store.YES,Field.Index.TOKENIZED);
Document docE = new Document();
docE.add(fieldE);
writer.addDocument(docA);
writer.addDocument(docB);
writer.addDocument(docC);
writer.addDocument(docD);
writer.addDocument(docE);
writer.close();
} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (LockObtainFailedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
AboutLuceneScore aus = new AboutLuceneScore();
aus.createIndex(); // 建立索引
try {
String keyword = "一人";
Term term = new Term("contents",keyword);
Query query = new TermQuery(term);
IndexSearcher searcher = new IndexSearcher(aus.path);
Date startTime = new Date();
Hits hits = searcher.search(query);
TermDocs termDocs = searcher.getIndexReader().termDocs(term);
while(termDocs.next()){
System.out.print("搜索关键字<"+keyword+">在编号为 "+termDocs.doc());
System.out.println(" 的Document中出现过 "+termDocs.freq()+" 次");
}
System.out.println("********************************************************************");
for(int i=0;i<hits.length();i++){
System.out.println("Document的内部编号为 : "+hits.id(i));
System.out.println("Document内容为 : "+hits.doc(i));
System.out.println("Document得分为 : "+hits.score(i));
Explanation e = searcher.explain(query, hits.id(i));
System.out.println("Explanation为 : \n"+e);
System.out.println("Document对应的Explanation的一些参数值如下: ");
System.out.println("Explanation的getValue()为 : "+e.getValue());
System.out.println("Explanation的getDescription()为 : "+e.getDescription());
System.out.println("********************************************************************");
}
System.out.println("共检索出符合条件的Document "+hits.length()+" 个。");
Date finishTime = new Date();
long timeOfSearch = finishTime.getTime() - startTime.getTime();
System.out.println("本次搜索所用的时间为 "+timeOfSearch+" ms");
} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
该测试类中实现了一个建立索引的方法createIndex()方法;然后通过检索一个关键字“一人”,获取到与它相关的Document的信息。
打印出结果的第一部分为:这个检索关键字“一人”在每个Document中出现的次数。
打印出结果的第二部分为:相关的Explanation及其得分情况的信息。
测试结果输出如下所示:
搜索关键字<一人>在编号为 0 的Document中出现过 1 次
搜索关键字<一人>在编号为 1 的Document中出现过 1 次
搜索关键字<一人>在编号为 2 的Document中出现过 1 次
搜索关键字<一人>在编号为 3 的Document中出现过 2 次
搜索关键字<一人>在编号为 4 的Document中出现过 2 次
********************************************************************
Document的内部编号为 : 0
Document内容为 : Document<stored/uncompressed,indexed,tokenized<contents:一人>>
Document得分为 : 0.81767845
Explanation为 :
0.81767845 = (MATCH) fieldWeight(contents:一人 in 0), product of:
1.0 = tf(termFreq(contents:一人)=1)
0.81767845 = idf(docFreq=5)
1.0 = fieldNorm(field=contents, doc=0)
Document对应的Explanation的一些参数值如下:
Explanation的getValue()为 : 0.81767845
Explanation的getDescription()为 : fieldWeight(contents:一人 in 0), product of:
********************************************************************
Document的内部编号为 : 3
Document内容为 : Document<stored/uncompressed,indexed,tokenized<contents:一人 做事 一人当 一人做事一人当>>
Document得分为 : 0.5059127
Explanation为 :
0.5059127 = (MATCH) fieldWeight(contents:一人 in 3), product of:
1.4142135 = tf(termFreq(contents:一人)=2)
0.81767845 = idf(docFreq=5)
0.4375 = fieldNorm(field=contents, doc=3)
Document对应的Explanation的一些参数值如下:
Explanation的getValue()为 : 0.5059127
Explanation的getDescription()为 : fieldWeight(contents:一人 in 3), product of:
********************************************************************
Document的内部编号为 : 4
Document内容为 : Document<stored/uncompressed,indexed,tokenized<contents:一人 做事 一人當 一人做事一人當>>
Document得分为 : 0.5059127
Explanation为 :
0.5059127 = (MATCH) fieldWeight(contents:一人 in 4), product of:
1.4142135 = tf(termFreq(contents:一人)=2)
0.81767845 = idf(docFreq=5)
0.4375 = fieldNorm(field=contents, doc=4)
Document对应的Explanation的一些参数值如下:
Explanation的getValue()为 : 0.5059127
Explanation的getDescription()为 : fieldWeight(contents:一人 in 4), product of:
********************************************************************
Document的内部编号为 : 1
Document内容为 : Document<stored/uncompressed,indexed,tokenized<contents:一人 之交 一人之交>>
Document得分为 : 0.40883923
Explanation为 :
0.40883923 = (MATCH) fieldWeight(contents:一人 in 1), product of:
1.0 = tf(termFreq(contents:一人)=1)
0.81767845 = idf(docFreq=5)
0.5 = fieldNorm(field=contents, doc=1)
Document对应的Explanation的一些参数值如下:
Explanation的getValue()为 : 0.40883923
Explanation的getDescription()为 : fieldWeight(contents:一人 in 1), product of:
********************************************************************
Document的内部编号为 : 2
Document内容为 : Document<stored/uncompressed,indexed,tokenized<contents:一人 之下 一人之下>>
Document得分为 : 0.40883923
Explanation为 :
0.40883923 = (MATCH) fieldWeight(contents:一人 in 2), product of:
1.0 = tf(termFreq(contents:一人)=1)
0.81767845 = idf(docFreq=5)
0.5 = fieldNorm(field=contents, doc=2)
Document对应的Explanation的一些参数值如下:
Explanation的getValue()为 : 0.40883923
Explanation的getDescription()为 : fieldWeight(contents:一人 in 2), product of:
********************************************************************
共检索出符合条件的Document 5 个。
本次搜索所用的时间为 79 ms
先从测试的输出结果进行分析,可以获得到如下信息:
■ 测试类中hits.score(i)的值与Explanation的getValue()的值是一样的,即Lucene默认使用的得分;
■ 默认情况下,Lucene按照Document的得分进行排序检索结果;
■ 默认情况下,如果两个Document的得分相同,按照Document的内部编号进行排序,比如上面编号为(3和4)、(1和2)是两组得分相同的Document,结果排序时按照Document的编号进行了排序;
通过从IndexSearcher类中的explain方法:
public Explanation explain(Weight weight, int doc) throws IOException {
return weight.explain(reader, doc);
}
可以看出,实际上是调用了Weight接口类中的explain()方法,而Weight是与一个Query相关的,它记录了一次查询构造的Query的情况,从而保证一个Query实例可以重用。
具体地,可以在实现Weight接口的具体类TermWeight中追溯到explain()方法,而TermWeight类是一个内部类,定义在TermQuery类内部。TermWeight类的explain()方法如下所示:
public Explanation explain(IndexReader reader, int doc)
throws IOException {
ComplexExplanation result = new ComplexExplanation();
result.setDescription("weight("+getQuery()+" in "+doc+"), product of:");
Explanation idfExpl = new Explanation(idf, "idf(docFreq=" + reader.docFreq(term) + ")");
// explain query weight
Explanation queryExpl = new Explanation();
queryExpl.setDescription("queryWeight(" + getQuery() + "), product of:");
Explanation boostExpl = new Explanation(getBoost(), "boost");
if (getBoost() != 1.0f)
queryExpl.addDetail(boostExpl);
queryExpl.addDetail(idfExpl);
Explanation queryNormExpl = new Explanation(queryNorm,"queryNorm");
queryExpl.addDetail(queryNormExpl);
queryExpl.setValue(boostExpl.getValue() *idfExpl.getValue() *queryNormExpl.getValue());
result.addDetail(queryExpl);
// 说明Field的权重
String field = term.field();
ComplexExplanation fieldExpl = new ComplexExplanation();
fieldExpl.setDescription("fieldWeight("+term+" in "+doc+"), product of:");
Explanation tfExpl = scorer(reader).explain(doc);
fieldExpl.addDetail(tfExpl);
fieldExpl.addDetail(idfExpl);
Explanation fieldNormExpl = new Explanation();
byte[] fieldNorms = reader.norms(field);
float fieldNorm =
fieldNorms!=null ? Similarity.decodeNorm(fieldNorms[doc]) : 0.0f;
fieldNormExpl.setValue(fieldNorm);
fieldNormExpl.setDescription("fieldNorm(field="+field+", doc="+doc+")");
fieldExpl.addDetail(fieldNormExpl);
fieldExpl.setMatch(Boolean.valueOf(tfExpl.isMatch()));
fieldExpl.setValue(tfExpl.getValue() *idfExpl.getValue() *fieldNormExpl.getValue());
result.addDetail(fieldExpl);
result.setMatch(fieldExpl.getMatch());
// combine them
result.setValue(queryExpl.getValue() * fieldExpl.getValue());
if (queryExpl.getValue() == 1.0f)
return fieldExpl;
return result;
}
根据检索结果,以及上面的TermWeight类的explain()方法,可以看出输出的字符串部分正好一一对应,比如:idf(Inverse Document Frequency,即反转文档频率)、fieldNorm、fieldWeight。
检索结果的第一个Document的信息:
Document的内部编号为 : 0
Document内容为 : Document<stored/uncompressed,indexed,tokenized<contents:一人>>
Document得分为 : 0.81767845
Explanation为 :
0.81767845 = (MATCH) fieldWeight(contents:一人 in 0), product of:
1.0 = tf(termFreq(contents:一人)=1)
0.81767845 = idf(docFreq=5)
1.0 = fieldNorm(field=contents, doc=0)
Document对应的Explanation的一些参数值如下:
Explanation的getValue()为 : 0.81767845
Explanation的getDescription()为 : fieldWeight(contents:一人 in 0), product of:
tf的计算
上面的tf值Term Frequency,即词条频率,可以在org.apache.lucene.search.Similarity类中看到具体地说明。在Lucene中,并不是直接使用的词条的频率,而实际使用的词条频率的平方根,即:
tf(t in d)
= |
frequency½ |
这是使用org.apache.lucene.search.Similarity类的子类DefaultSimilarity中的方法计算的,如下:
/** Implemented as <code>sqrt(freq)</code>. */
public float tf(float freq) {
return (float)Math.sqrt(freq);
}
即:某个Document的tf = 检索的词条在该Document中出现次数freq取平方根值
也就是freq的平方根。
例如,从我们的检索结果来看:
搜索关键字<一人>在编号为 0 的Document中出现过 1 次
搜索关键字<一人>在编号为 1 的Document中出现过 1 次
搜索关键字<一人>在编号为 2 的Document中出现过 1 次
搜索关键字<一人>在编号为 3 的Document中出现过 2 次
搜索关键字<一人>在编号为 4 的Document中出现过 2 次
各个Document的tf计算如下所示:
编号为0的Document的 tf 为: (float)Math.sqrt(1) = 1.0;
编号为1的Document的 tf 为: (float)Math.sqrt(1) = 1.0;
编号为2的Document的 tf 为: (float)Math.sqrt(1) = 1.0;
编号为3的Document的 tf 为: (float)Math.sqrt(2) = 1.4142135;
编号为4的Document的 tf 为: (float)Math.sqrt(2) = 1.4142135;
idf的计算
检索结果中,每个检索出来的Document的都对应一个idf,在DefaultSimilarity类中可以看到idf计算的实现方法,如下:
/** Implemented as <code>log(numDocs/(docFreq+1)) + 1</code>. */
public float idf(int docFreq, int numDocs) {
return (float)(Math.log(numDocs/(double)(docFreq+1)) + 1.0);
}
其中,docFreq是根据指定关键字进行检索,检索到的Document的数量,我们测试的docFreq=5;numDocs是指索引文件中总共的Document的数量,我们的测试比较特殊,将全部的Document都检索出来了,我们测试的numDocs=5。
各个Document的idf的计算如下所示:
编号为0的Document的 idf 为:(float)(Math.log(5/(double)(5+1)) + 1.0) = 0.81767845;
编号为1的Document的 idf 为:(float)(Math.log(5/(double)(5+1)) + 1.0) = 0.81767845;
编号为2的Document的 idf 为:(float)(Math.log(5/(double)(5+1)) + 1.0) = 0.81767845;
编号为3的Document的 idf 为:(float)(Math.log(5/(double)(5+1)) + 1.0) = 0.81767845;
编号为4的Document的 idf 为:(float)(Math.log(5/(double)(5+1)) + 1.0) = 0.81767845;
lengthNorm的计算
在DefaultSimilarity类中可以看到lengthNorm计算的实现方法,如下:
public float lengthNorm(String fieldName, int numTerms) {
return (float)(1.0 / Math.sqrt(numTerms));
}
各个Document的lengthNorm的计算如下所示:
编号为0的Document的 lengthNorm 为:(float)(1.0 / Math.sqrt(1)) = 1.0/1.0 = 1.0;
编号为1的Document的 lengthNorm 为:(float)(1.0 / Math.sqrt(1)) = 1.0/1.0 = 1.0;
编号为2的Document的 lengthNorm 为:(float)(1.0 / Math.sqrt(1)) = 1.0/1.0 = 1.0;
编号为3的Document的 lengthNorm 为:(float)(1.0 / Math.sqrt(2)) = 1.0/1.4142135 = 0.7071068;
编号为4的Document的 lengthNorm 为:(float)(1.0 / Math.sqrt(2)) = 1.0/1.4142135 = 0.7071068;
关于fieldNorm
fieldNorm是在建立索引的时候写入的,而检索的时候需要从索引文件中读取,然后通过解码,得到fieldNorm的float型值,用于计算Document的得分。
在org.apache.lucene.search.TermQuery.TermWeight类中,explain方法通过打开的IndexReader流读取fieldNorm,写入索引文件的是byte[]类型,需要解码,如下所示:
byte[] fieldNorms = reader.norms(field);
float fieldNorm = fieldNorms!=null ? Similarity.decodeNorm(fieldNorms[doc]) : 0.0f;
调用Similarity类的decodeNorm方法,将byte[]类型值转化为float浮点值:
public static float decodeNorm(byte b) {
return NORM_TABLE[b & 0xFF]; // & 0xFF maps negative bytes to positive above 127
}
这样,一个浮点型的fieldNorm的值就被读取出来了,可以参加一些运算,最终实现Lucene的Document的得分的计算。
queryWeight的计算
queryWeight的计算可以在org.apache.lucene.search.TermQuery.TermWeight类中的sumOfSquaredWeights方法中看到计算的实现:
public float sumOfSquaredWeights() {
queryWeight = idf * getBoost(); // compute query weight
return queryWeight * queryWeight; // square it
}
其实默认情况下,queryWeight = idf,因为Lucune中默认的激励因子boost = 1.0。
各个Document的queryWeight的计算如下所示:
queryWeight = 0.81767845 * 0.81767845 = 0.6685980475944025;
queryNorm的计算
queryNorm的计算在DefaultSimilarity类中实现,如下所示:
/** Implemented as <code>1/sqrt(sumOfSquaredWeights)</code>. */
public float queryNorm(float sumOfSquaredWeights) {
return (float)(1.0 / Math.sqrt(sumOfSquaredWeights));
}
这里,sumOfSquaredWeights的计算是在org.apache.lucene.search.TermQuery.TermWeight类中的sumOfSquaredWeights方法实现:
public float sumOfSquaredWeights() {
queryWeight = idf * getBoost(); // compute query weight
return queryWeight * queryWeight; // square it
}
其实默认情况下,sumOfSquaredWeights = idf * idf,因为Lucune中默认的激励因子boost = 1.0。
上面测试例子中sumOfSquaredWeights的计算如下所示:
sumOfSquaredWeights = 0.81767845*0.81767845 = 0.6685980475944025;
然后,就可以计算queryNorm的值了,计算如下所示:
queryNorm = (float)(1.0 / Math.sqrt(0.6685980475944025) = 1.2229746301862302962735534977105;
value的计算
org.apache.lucene.search.TermQuery.TermWeight类类中还定义了一个value成员:
private float value;
关于value的计算,可以在它的子类org.apache.lucene.search.TermQuery.TermWeight类中看到计算的实现:
public void normalize(float queryNorm) {
this.queryNorm = queryNorm;
queryWeight *= queryNorm; // normalize query weight
value = queryWeight * idf; // idf for document
}
这里,使用normalize方法计算value的值,即:
value = queryNorm * queryWeight * idf;
上面测试例子中value的值计算如下:
value = 1.2229746301862302962735534977105 * 0.6685980475944025 * 0.81767845 = 0.66859804759440249999999999999973;
关于fieldWeight
从检索结果中,可以看到:
0.81767845 = (MATCH) fieldWeight(contents:一人 in 0), product of:
字符串"(MATCH) "的输在ComplexExplanation类中的getSummary方法中可以看到:
protected String getSummary() {
if (null == getMatch())
return super.getSummary();
return getValue() + " = "
+ (isMatch() ? "(MATCH) " : "(NON-MATCH) ")
+ getDescription();
}
这个fieldWeight的值其实和Document的得分是相等的,先看这个fieldWeight是如何计算出来的,在org.apache.lucene.search.TermQuery.TermWeight类中的explain方法中可以看到:
ComplexExplanation fieldExpl
= new ComplexExplanation();
fieldExpl
.setDescription("fieldWeight("+term+" in "+doc+
"), product of:");
Explanation tfExpl = scorer(reader).explain(doc);
fieldExpl
.addDetail(tfExpl);
fieldExpl
.addDetail(idfExpl);
Explanation fieldNormExpl = new Explanation();
byte[] fieldNorms = reader.norms(field);
float fieldNorm =
fieldNorms!=null ? Similarity.decodeNorm(fieldNorms[doc]) : 0.0f;
fieldNormExpl.setValue(fieldNorm);
fieldNormExpl.setDescription("fieldNorm(field="+field+", doc="+doc+")");
fieldExpl
.addDetail(fieldNormExpl);
fieldExpl
.setMatch(Boolean.valueOf(tfExpl.isMatch()));
fieldExpl
.setValue(tfExpl.getValue() *
idfExpl.getValue() *
fieldNormExpl.getValue());
result.addDetail(fieldExpl
);
result.setMatch(fieldExpl
.getMatch());
// combine them
result.setValue(queryExpl.getValue() * fieldExpl
.getValue());
if (queryExpl.getValue() == 1.0f)
return fieldExpl
;
上面,ComplexExplanation fieldExpl被设置了很多项内容,我们就从这里来获取fieldWeight的计算的实现。
关键是在下面进行了计算:
fieldExpl
.setValue(tfExpl.getValue() *
idfExpl.getValue() *
fieldNormExpl.getValue());
使用计算式表示就是
fieldWeight = tf * idf * fieldNorm
fieldNorm的值因为是在建立索引的时候写入到索引文件中的,索引只需要从上面的测试结果中取来,进行如下关于Document的分数的计算的验证。
使用我们这个例子来计算检索出来的Docuyment的fieldWeight,需要用到前面计算出来的结果,如下所示:
编号为0的Document的 fieldWeight 为:1.0 * 0.81767845 * 1.0 = 0.81767845;
编号为1的Document的 fieldWeight 为:1.0 * 0.81767845 * 0.5 = 0.408839225;
编号为2的Document的 fieldWeight 为:1.0 * 0.81767845 * 0.5 = 0.408839225;
编号为3的Document的 fieldWeight 为:1.4142135 * 0.81767845 * 0.4375 = 0.5059127074089703125;
编号为4的Document的 fieldWeight 为:1.4142135 * 0.81767845 * 0.4375 = 0.5059127074089703125;
对比一下,其实检索结果中Document的得分就是这个fieldWeight的值,验证后,正好相符(注意:我这里没有进行舍入运算)。
总结说明
上面的计算得分是按照Lucene默认设置的情况下进行的,比如激励因子的默认值为1.0,它体现的是一个Document的重要性,即所谓的fieldWeight。
不仅可以通过为一个Document设置激励因子boost,而且可以通过为一个Document中的Field设置boost,因为一个Document的权重体现在它当中的Field上,即上面计算出来的fieldWeight与Document的得分是相等的。
提高一个Document的激励因子boost,可以使该Document被检索出来的默认排序靠前,即说明比较重要。也就是说,修改激励因子boost能够改变检索结果的排序。
发表评论
-
全文检索的基本原理
2010-02-25 10:22 877一、总论 根据http://lucene.apache.or ... -
lucene 分组 bobo-Browse 排序的问题
2010-02-01 16:18 2224今天碰到了一个问题,用bobo分组后对价格升序 居然100 ... -
开源搜索引擎
2010-02-01 14:31 1695开放源代码搜索引擎为 ... -
lucene中的filter器群组及其缓存大盘点
2010-01-20 23:18 1202lucene中的filter其实并不起眼,大家对其对性能的影响 ... -
利用bobo-browse 实现lucene的分组统计功能
2010-01-18 17:50 2940bobo-browse 是一用java写的lucene扩展组件 ... -
lucene Field部分参数设置含义
2009-11-07 17:51 1249<script type="text/ja ... -
刚下载,开始学习lucene时看的文章
2009-09-04 18:43 1433Lucene 2.0.0下载安装及测试 【下载】 下载链接 ... -
Lucene-2.3.1 阅读学习(42)
2009-09-04 18:42 946关于Hits类。 这个Hits类 ... -
Lucene 2.3.1 阅读学习(41)
2009-09-04 18:42 1413当执行Hits htis = search(query);这一 ... -
Lucene-2.3.1 源代码阅读学习(40)
2009-09-04 18:41 990关于Lucene检索结果的排序问题。 已经知道,Lucene ... -
Lucene-2.3.1 源代码阅读学习(39)
2009-09-04 18:41 1156关于Lucene得分的计算。 在IndexSearcher类 ... -
Lucene-2.3.1 源代码阅读学习(38)
2009-09-04 18:38 922关于QueryParser。 QueryParser是用来解 ... -
Lucene-2.3.1 源代码阅读学习(37)
2009-09-04 18:37 631关于MultiTermQuery查询。 这里研究继承自Mul ... -
Lucene-2.3.1 源代码阅读学习(36)
2009-09-04 18:37 808关于MultiTermQuery查询。 ... -
Lucene-2.3.1 源代码阅读学习(35)
2009-09-04 18:36 845关于MultiPhraseQuery(多短语查询)。 Mul ... -
Lucene-2.3.1 源代码阅读学习(34)
2009-09-04 18:36 640关于PhraseQuery。 PhraseQuery查询是将 ... -
Lucene-2.3.1 源代码阅读学习(33)
2009-09-04 18:35 871关于范围查询RangeQuery。 ... -
Lucene-2.3.1 源代码阅读学习(32)
2009-09-04 18:35 1157关于SpanQuery(跨度搜索),它是Query的子类,但是 ... -
Lucene-2.3.1 源代码阅读学习(31)
2009-09-04 18:34 874关于前缀查询PrefixQuery(前缀查询)。 准备工作就 ... -
Lucene-2.3.1 源代码阅读学习(30)
2009-09-04 18:34 1065关于Query的学习。 主要使用TermQuery和Bool ...
相关推荐
《Lucene-2.3.1 源代码阅读学习》 Lucene是Apache软件基金会的一个开放源码项目,它是一个高性能、全文本搜索库,为开发者提供了在Java应用程序中实现全文检索功能的基础架构。本篇文章将深入探讨Lucene 2.3.1版本...
总而言之,Lucene 2.3.1作为一款经典的搜索引擎框架,它的源代码不仅提供了学习信息检索理论的机会,也是实践和掌握Java编程、数据结构和算法的宝贵资源。通过对压缩包中的文件进行分析,开发者可以深入了解Lucene的...
通过深入学习和理解这些源代码文件,开发者可以更好地掌握 Lucene.Net 的核心功能,如索引构建、查询解析、搜索排序、分词和性能优化。这有助于在实际项目中实现高效、精确的全文搜索引擎。同时,研究源码也能提升对...
4.其中src文件夹内为全部源代码,WebRoot为web应用部署文件 5.本系统的最小有效组件集合为:(约定:以下“*.*”均表示目录下的所有单独文件,不包括文件夹,而“/s”则表示所有的文件夹及其内部内容) src\*.* /s ...
### Lucene+Solor知识点概述 #### 一、搜索引擎基础理论 **1.1 Google神话** - **起源与发展:** - Google成立于1998年,由Larry Page和Sergey Brin创立。 - 初期以PageRank算法为核心,有效解决了当时互联网...
- **开源协议**:使用Apache License 2.0协议,源代码完全开源,没有商业限制。 - **技术栈成熟**:使用当前最主流的J2EE开发框架和技术,易于学习和维护。 - **数据库支持广泛**:支持多种数据库,如MySQL、Oracle...
- **1.4.1 目录结构说明**:Solr项目的目录结构清晰,主要包括src/main/java下的源代码、src/main/resources下的资源文件等。 - **1.4.2 Solrhome说明**:Solrhome是Solr实例的工作目录,包含了索引数据、配置文件等...
- **1.4.1 目录结构说明**:Solr的核心源码主要由几个关键部分组成,如`src/main/java`包含Java源代码,`src/main/resources`存放配置文件等。 - **1.4.2 Solrhome说明**:Solrhome是Solr运行时使用的根目录,包含了...
CAS (Central Authentication Service) 是一种开放源代码的单点登录协议和服务实现,主要用于Web应用的安全身份验证。CAS支持跨域的身份验证管理,允许用户通过一个中心服务进行一次登录即可访问多个应用系统。 **...
2.3.1. 保存 ACL 数据确保持久性 2.3.2. 使用声明(Assert)来编写条件性的 ACL 规则 3. Zend_Auth 3.1. 简介 3.1.1. 适配器 3.1.2. 结果 3.1.3. 身份的持久(Persistence) 3.1.3.1. 在PHP Session 中的缺省...