Scoring Formula
1.coord (q,d), query coverage
/***/ @Override publicfloat coord (intint maxoverlap) { return overlap/(float) maxoverlap; }
For example:
Query: Query=title:search and Content:lucenen determine maximum coverage maxoverlap = 2
Index document content: 1. {title:search ***,content:lucenen * *}
Title and content all hit: overlap = 2 coord (q,d) = 2/2
2.{title:search ***,CONTENT:SOLR * *}
Only title hit: overlap = 1 coord (q,d) = 1/2
The means by which this parameter affects sequencing is to modify the word breaker to make tokens more hit term, raising the coord value
2.queryNorm (q), query the weight score, no effect on the result sorting, the same query the factor score consistent
/***/ @Override publicfloat querynorm (float sumofsquaredweights) { return (float) (1.0/math.sqrt (sumofsquaredweights)); }
Sumofsquaredweights Query Weight Score
Termquery weight, booleanquery weight
T in Q:term in query
The Booleanquery and termquery weights of a query are consistent, and the querynorm factor has no effect on the sorting results in the same query, but rather is used to compare the scores of the different queries.
∑ (TF (T in D) IDF (t) ^2 t.getboost () lengthnorm (t,d))
In parentheses, the fractional summation of each term parsed, for example: Query "Lucene and Solr", Lucene score + SOLR's score
3.TF (termfreq), the frequency of the term in which the term appears in the document
tf = sqrt (number of occurrences of term in this document)
/***/ @Override publicfloat tf (float freq) { return (float) math.sqrt (freq); }
The more times a query word appears in the document, the more important the document is
4.IDF (inversedocumentfreq inverse text frequency), Docfreq (number of documents appearing in the term), Numdocs of all documents
/***/ @Override publicfloat IDF (longlong numdocs) { return (float) (Math.log (numdocs/(double) ( docfreq+1)) + 1.0); }
5.t.getboost (), term in document query weights, SOLR call interface title:lucene^3
6.lengthNorm () term in document
/**implemented as * <code>state.getboost () *lengthnorm (numterms) </code>, where * <CODE>NUMTERMS&L T;/code> is {@linkfieldinvertstate#getlength ()} if {@link* #setDiscountOverlaps} is false, else it ' s {@link* Fieldinvertstate#getlength ()}-{@link* FIELDINVERTSTATE#GETNUMOVERLAP ()}. * * @lucene. Experimental*/@Override Public floatLengthnorm (fieldinvertstate state) {Final intnumterms; if(discountoverlaps) numterms= State.getlength ()-State.getnumoverlap (); Elsenumterms=state.getlength (); returnState.getboost () * ((float) (1.0/math.sqrt (numterms)); }
The factor is made up of two parts
1.state.getboost (), change value is the field weight specified when the index was created
2. (float) (1.0/math.sqrt (numterms)), numterms represents the length of the term corresponding to field, if Title:lucene numterms corresponds to the document "Title:lucenen" than the document " Title:lucene and Solr "important
Research on Lucene scoring mechanism