English 中文(简体)
Lucene: 核心计算
原标题:Lucene: Score calculation with a PrefixQuery

我对用固定住房进行记分计算存在问题。 为了将每份文件的分数换成指数,我利用了缩略语来改变文件的推动。 然后,我设立了搜查处,但结果没有根据提升变化。 看来,它完全没有做固定工作。 请检查我的以下法典:

 @Test
 public void testNormsDocBoost() throws Exception {
    Directory dir = new RAMDirectory();
    IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_CURRENT), true,
            IndexWriter.MaxFieldLength.LIMITED);
    Document doc1 = new Document();
    Field f1 = new Field("contents", "common1", Field.Store.YES, Field.Index.ANALYZED);
    doc1.add(f1);
    doc1.setBoost(100);
    writer.addDocument(doc1);
    Document doc2 = new Document();
    Field f2 = new Field("contents", "common2", Field.Store.YES, Field.Index.ANALYZED);
    doc2.add(f2);
    doc2.setBoost(200);
    writer.addDocument(doc2);
    Document doc3 = new Document();
    Field f3 = new Field("contents", "common3", Field.Store.YES, Field.Index.ANALYZED);
    doc3.add(f3);
    doc3.setBoost(300);
    writer.addDocument(doc3);
    writer.close();

    IndexReader reader = IndexReader.open(dir);
    IndexSearcher searcher = new IndexSearcher(reader);

    TopDocs docs = searcher.search(new PrefixQuery(new Term("contents", "common")), 10);
    for (ScoreDoc doc : docs.scoreDocs) {
        System.out.println("docid : " + doc.doc + " score : " + doc.score + " "
                + searcher.doc(doc.doc).get("contents"));
    }
} 

产出如下:

 docid : 0 score : 1.0 common1
 docid : 1 score : 1.0 common2
 docid : 2 score : 1.0 common3
问题回答

否则,Prefix Query就重新提出了使用ConstantS Query的询问,这使每一份配对文件有1.0分。 我认为,这样做是为了更快地确定质量。 因此,你的推动力被忽视。

如果您希望提高工作效率,就请您使用SCORING_BOOLEAN_questRY_REWRITE。 始终如一地接受您的预先调查。 见。 。

为了脱胎,你可以使用搜索器。 解释。

这是预期的行为。 下面是Lucene creator s Doug Clement的解释:

A PrefixQuery is equivalent to a query containing all the terms matching the prefix, and is hence usually contains a lot of terms. With such a big query, matching documents are likely to contain fewer of the query terms and the match is thus weaker.

http://www.lucidimagination.com/search/document/cb1f4f8a646d14/prefixquery_scoring#4e7977e52576aed8”rel=“nofollow noreferer”原始,引自该引书。

用卢塞内语来说,通常最好在一套文件中只将记分作为相对的权责衡量尺度。 计分的绝对值将根据许多因素变化,这些因素不应像现在一样使用。

UPDATE
The explanation from Cutting refers to an older version of Lucene. Thus the answer from bajafresh4life is the correct one.

www.un.org/Depts/DGACM/index_spanish.htm 改变《标准方法》

Basfresh4life建议打电话setRewriteMethod。 然而,这并不是你如何改变卢塞内的情况。 净额 在C#中如何做到这一点:

。 同样:

protected internal virtual Query NewPrefixQuery(Term prefix)
{
    return new PrefixQuery(prefix) { RewriteMethod = multiTermRewriteMethod };
}

您可以通过使用<条码><>>对<条码>财产进行即时解释。

var parser = new QueryParser( Version.LUCENE_30, field, analyzer );
parser.MultiTermRewriteMethod = MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE;

请注意,这将改变其他查询的行为,而不仅仅是预先确定的问题。 为了只影响预先定点,你可以下级<代码>。 缩略语 因此,被退回的<代码>Prefixery的施工人使用你选择的重写法。

www.un.org/Depts/DGACM/index_spanish.htm 何种标准方法使用

但是,这似乎并没有给我确定。 我实际上使用<代码>的uck子更好。 MultiTermQuery.CONashT_SCORE_BOOLEAN_questRY_REWRITE/code. 在对这种方法的说明中,它说:

同SCORING_BOOLEAN_questRY_REEPA 除分数外,未计算。 相反,每份配对文件获得的分数与点火的升值持平。

但是,这可能是因为我还分级了<代码> Prefixery Qu/code>和超代版ReWrite,以指定我所希望的记分为助推。

在进行了相当数量的清点之后,我最后指出,虽然我试图使用SCORING_BOOLEAN_questRY_REWR,DefaultSimilarity.Query Norm,当返回值用于Wels.Normalize时,则与我的分数相提并论。 Query.Wala





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签