I have the following Lucene Explanation:
{1.25 = (MATCH) sum of:
0.5 = (MATCH) weight(Caption:vrom^0.5 in 0) [MySimilarity], result of:
0.5 = score(doc=0,freq=1 = termFreq=1
), product of:
0.5 = queryWeight, product of:
0.5 = boost
1 = idf(docFreq=1, maxDocs=4)
1 = queryNorm
1 = fieldWeight in 0, product of:
1 = tf(freq=1), with freq of:
1 = termFreq=1
1 = idf(docFreq=1, maxDocs=4)
1 = fieldNorm(doc=0)
0.75 = (MATCH) weight(Caption:vroma^0.75 in 0) [MySimilarity], result of:
0.75 = score(doc=0,freq=1 = termFreq=1
), product of:
0.75 = queryWeight, product of:
0.75 = boost
1 = idf(docFreq=1, maxDocs=4)
1 = queryNorm
1 = fieldWeight in 0, product of:
1 = tf(freq=1), with freq of:
1 = termFreq=1
1 = idf(docFreq=1, maxDocs=4)
1 = fieldNorm(doc=0)
}
and I want to filter the matching results by their query weight as a MAX match and not a sum of match.
What i need to do is, from each document, I want to take the highest number given in every clause. (in this example i would like to take 0.75 as the matching score not 1.25). Is this possible, or even right, to do so?
What I have done so far is to create a Similarity in order to change the way the score is calculated, but I am still missing the part of getting the MAX instead of SUM as a result.
I am using Lucene .Net version 4.8(beta).
Thank you in advance!
No need to modify the Similarity to do that. Instead of a boolean query, use a DisjunctionMaxQuery .
Thanks for the solution but I still have a problem. When I try to do that I get the same results as before. My code is the following (I used examples from here ) :
BooleanQuery finalQuery = new BooleanQuery();
DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.01f);
Query query = new FuzzyQuery(new Term("Caption", "roma"));
q1.Add(query);
finalQuery.Add(q1, Occur.MUST);
The results I get are (the same as in the question) :
{1.25 = (MATCH) sum of:
0.5 = (MATCH) weight(Caption:vrom^0.5 in 0) [MySimilarity], result of:
0.5 = score(doc=0,freq=1 = termFreq=1
), product of:
0.5 = queryWeight, product of:
0.5 = boost
1 = idf(docFreq=1, maxDocs=4)
1 = queryNorm
1 = fieldWeight in 0, product of:
1 = tf(freq=1), with freq of:
1 = termFreq=1
1 = idf(docFreq=1, maxDocs=4)
1 = fieldNorm(doc=0)
0.75 = (MATCH) weight(Caption:vroma^0.75 in 0) [MySimilarity], result of:
0.75 = score(doc=0,freq=1 = termFreq=1
), product of:
0.75 = queryWeight, product of:
0.75 = boost
1 = idf(docFreq=1, maxDocs=4)
1 = queryNorm
1 = fieldWeight in 0, product of:
1 = tf(freq=1), with freq of:
1 = termFreq=1
1 = idf(docFreq=1, maxDocs=4)
1 = fieldNorm(doc=0)
}
I tried it and without modify the Similarity but I had the same. The results in this case are :
{0.505973 = (MATCH) sum of:
0.2023892 = (MATCH) weight(Caption:vrom^0.5 in 0) [DefaultSimilarity], result of:
0.2023892 = score(doc=0,freq=1 = termFreq=1
), product of:
0.3187582 = queryWeight, product of:
0.5 = boost
1.693147 = idf(docFreq=1, maxDocs=4)
0.3765274 = queryNorm
0.6349302 = fieldWeight in 0, product of:
1 = tf(freq=1), with freq of:
1 = termFreq=1
1.693147 = idf(docFreq=1, maxDocs=4)
0.375 = fieldNorm(doc=0)
0.3035838 = (MATCH) weight(Caption:vroma^0.75 in 0) [DefaultSimilarity], result of:
0.3035838 = score(doc=0,freq=1 = termFreq=1
), product of:
0.4781373 = queryWeight, product of:
0.75 = boost
1.693147 = idf(docFreq=1, maxDocs=4)
0.3765274 = queryNorm
0.6349302 = fieldWeight in 0, product of:
1 = tf(freq=1), with freq of:
1 = termFreq=1
1.693147 = idf(docFreq=1, maxDocs=4)
0.375 = fieldNorm(doc=0)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.