📄 similarity.html
字号:
<br> <br> <table cellpadding="1" cellspacing="0" border="0"n align="center"> <tr> <td valign="middle" align="right" rowspan="1"> norm(t,d) = <A HREF="../../../../org/apache/lucene/document/Document.html#getBoost()"><CODE>doc.getBoost()</CODE></A> · <A HREF="../../../../org/apache/lucene/search/Similarity.html#lengthNorm(java.lang.String, int)"><CODE>lengthNorm(field)</CODE></A> · </td> <td valign="bottom" align="center" rowspan="1"> <big><big><big>∏</big></big></big> </td> <td valign="middle" align="right" rowspan="1"> <A HREF="../../../../org/apache/lucene/document/Fieldable.html#getBoost()"><CODE>f.getBoost</CODE></A>() </td> </tr> <tr valigh="top"> <td></td> <td align="center"><small>field <i><b>f</b></i> in <i>d</i> named as <i><b>t</b></i></small></td> <td></td> </tr> </table> <br> <br> However the resulted <i>norm</i> value is <A HREF="../../../../org/apache/lucene/search/Similarity.html#encodeNorm(float)"><CODE>encoded</CODE></A> as a single byte before being stored. At search time, the norm byte value is read from the index <A HREF="../../../../org/apache/lucene/store/Directory.html" title="class in org.apache.lucene.store"><CODE>directory</CODE></A> and <A HREF="../../../../org/apache/lucene/search/Similarity.html#decodeNorm(byte)"><CODE>decoded</CODE></A> back to a float <i>norm</i> value. This encoding/decoding, while reducing index size, comes with the price of precision loss - it is not guaranteed that decode(encode(x)) = x. For instance, decode(encode(0.89)) = 0.75. Also notice that search time is too late to modify this <i>norm</i> part of scoring, e.g. by using a different <A HREF="../../../../org/apache/lucene/search/Similarity.html" title="class in org.apache.lucene.search"><CODE>Similarity</CODE></A> for search. <br> <br> </li> </ol>
<P>
<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/lucene/search/Similarity.html#setDefault(org.apache.lucene.search.Similarity)"><CODE>setDefault(Similarity)</CODE></A>, <CODE>IndexWriter#setSimilarity(Similarity)</CODE>, <A HREF="../../../../org/apache/lucene/search/Searcher.html#setSimilarity(org.apache.lucene.search.Similarity)"><CODE>Searcher.setSimilarity(Similarity)</CODE></A>, <A HREF="../../../../serialized-form.html#org.apache.lucene.search.Similarity">Serialized Form</A></DL>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#Similarity()">Similarity</A></B>()</CODE>
<BR>
</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>abstract float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#coord(int, int)">coord</A></B>(int overlap, int maxOverlap)</CODE>
<BR>
Computes a score factor based on the fraction of all query terms that a document contains.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#decodeNorm(byte)">decodeNorm</A></B>(byte b)</CODE>
<BR>
Decodes a normalization factor stored in an index.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static byte</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#encodeNorm(float)">encodeNorm</A></B>(float f)</CODE>
<BR>
Encodes a normalization factor for storage in an index.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static <A HREF="../../../../org/apache/lucene/search/Similarity.html" title="class in org.apache.lucene.search">Similarity</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#getDefault()">getDefault</A></B>()</CODE>
<BR>
Return the default Similarity implementation used by indexing and search code.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static float[]</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#getNormDecoder()">getNormDecoder</A></B>()</CODE>
<BR>
Returns a table for decoding normalization bytes.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#idf(java.util.Collection, org.apache.lucene.search.Searcher)">idf</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A> terms, <A HREF="../../../../org/apache/lucene/search/Searcher.html" title="class in org.apache.lucene.search">Searcher</A> searcher)</CODE>
<BR>
Computes a score factor for a phrase.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>abstract float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#idf(int, int)">idf</A></B>(int docFreq, int numDocs)</CODE>
<BR>
Computes a score factor based on a term's document frequency (the number of documents which contain the term).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#idf(org.apache.lucene.index.Term, org.apache.lucene.search.Searcher)">idf</A></B>(<A HREF="../../../../org/apache/lucene/index/Term.html" title="class in org.apache.lucene.index">Term</A> term, <A HREF="../../../../org/apache/lucene/search/Searcher.html" title="class in org.apache.lucene.search">Searcher</A> searcher)</CODE>
<BR>
Computes a score factor for a simple term.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>abstract float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#lengthNorm(java.lang.String, int)">lengthNorm</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> fieldName, int numTokens)</CODE>
<BR>
Computes the normalization value for a field given the total number of terms contained in a field.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>abstract float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#queryNorm(float)">queryNorm</A></B>(float sumOfSquaredWeights)</CODE>
<BR>
Computes the normalization value for a query given the sum of the squared weights of each of the query terms.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#setDefault(org.apache.lucene.search.Similarity)">setDefault</A></B>(<A HREF="../../../../org/apache/lucene/search/Similarity.html" title="class in org.apache.lucene.search">Similarity</A> similarity)</CODE>
<BR>
Set the default Similarity implementation used by indexing and search code.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>abstract float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#sloppyFreq(int)">sloppyFreq</A></B>(int distance)</CODE>
<BR>
Computes the amount of a sloppy phrase match, based on an edit distance.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>abstract float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#tf(float)">tf</A></B>(float freq)</CODE>
<BR>
Computes a score factor based on a term or phrase's frequency in a document.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/lucene/search/Similarity.html#tf(int)">tf</A></B>(int freq)</CODE>
<BR>
Computes a score factor based on a term or phrase's frequency in a document.</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ FIELD DETAIL =========== -->
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="Similarity()"><!-- --></A><H3>
Similarity</H3>
<PRE>
public <B>Similarity</B>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="setDefault(org.apache.lucene.search.Similarity)"><!-- --></A><H3>
setDefault</H3>
<PRE>
public static void <B>setDefault</B>(<A HREF="../../../../org/apache/lucene/search/Similarity.html" title="class in org.apache.lucene.search">Similarity</A> similarity)</PRE>
<DL>
<DD>Set the default Similarity implementation used by indexing and search code.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/lucene/search/Searcher.html#setSimilarity(org.apache.lucene.search.Similarity)"><CODE>Searcher.setSimilarity(Similarity)</CODE></A>, <CODE>IndexWriter#setSimilarity(Similarity)</CODE></DL>
</DD>
</DL>
<HR>
<A NAME="getDefault()"><!-- --></A><H3>
getDefault</H3>
<PRE>
public static <A HREF="../../../../org/apache/lucene/search/Similarity.html" title="class in org.apache.lucene.search">Similarity</A> <B>getDefault</B>()</PRE>
<DL>
<DD>Return the default Similarity implementation used by indexing and search code. <p>This is initially an instance of <A HREF="../../../../org/apache/lucene/search/DefaultSimilarity.html" title="class in org.apache.lucene.search"><CODE>DefaultSimilarity</CODE></A>.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/lucene/search/Searcher.html#setSimilarity(org.apache.lucene.search.Similarity)"><CODE>Searcher.setSimilarity(Similarity)</CODE></A>, <CODE>IndexWriter#setSimilarity(Similarity)</CODE></DL>
</DD>
</DL>
<HR>
<A NAME="decodeNorm(byte)"><!-- --></A><H3>
decodeNorm</H3>
<PRE>
public static float <B>decodeNorm</B>(byte b)</PRE>
<DL>
<DD>Decodes a normalization factor stored in an index.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/lucene/search/Similarity.html#encodeNorm(float)"><CODE>encodeNorm(float)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getNormDecoder()"><!-- --></A><H3>
getNormDecoder</H3>
<PRE>
public static float[] <B>getNormDecoder</B>()</PRE>
<DL>
<DD>Returns a table for decoding normalization bytes.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/lucene/search/Similarity.html#encodeNorm(float)"><CODE>encodeNorm(float)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="lengthNorm(java.lang.String, int)"><!-- --></A><H3>
lengthNorm</H3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -