mirror of https://github.com/apache/lucene.git
- LUCENE-891 doc patch
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@541702 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9fbee15671
commit
304884c660
|
@ -52,8 +52,8 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
TermQuery tq = new TermQuery(new Term("fieldName", "term"));
|
TermQuery tq = new TermQuery(new Term("fieldName", "term"));
|
||||||
</pre>In this example, the <a href="Query.html">Query</a> identifies all <a
|
</pre>In this example, the <a href="Query.html">Query</a> identifies all <a
|
||||||
href="../document/Document.html">Document</a>s that have the <a
|
href="../document/Document.html">Document</a>s that have the <a
|
||||||
href="../document/Field.html">Field</a> named <tt>"fieldName"</tt> and
|
href="../document/Field.html">Field</a> named <tt>"fieldName"</tt>
|
||||||
contain the word <tt>"term"</tt>.
|
containing the word <tt>"term"</tt>.
|
||||||
</p>
|
</p>
|
||||||
<h4>
|
<h4>
|
||||||
<a href="BooleanQuery.html">BooleanQuery</a>
|
<a href="BooleanQuery.html">BooleanQuery</a>
|
||||||
|
@ -70,15 +70,15 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
describing how that sub-query is combined with the other clauses:
|
describing how that sub-query is combined with the other clauses:
|
||||||
<ol>
|
<ol>
|
||||||
|
|
||||||
<li><p>SHOULD -- Use this operator when a clause can occur in the result set, but is not required.
|
<li><p>SHOULD — Use this operator when a clause can occur in the result set, but is not required.
|
||||||
If a query is made up of all SHOULD clauses, then every document in the result
|
If a query is made up of all SHOULD clauses, then every document in the result
|
||||||
set matches at least one of these clauses.</p></li>
|
set matches at least one of these clauses.</p></li>
|
||||||
|
|
||||||
<li><p>MUST -- Use this operator when a clause is required to occur in the result set. Every
|
<li><p>MUST — Use this operator when a clause is required to occur in the result set. Every
|
||||||
document in the result set will match
|
document in the result set will match
|
||||||
all such clauses.</p></li>
|
all such clauses.</p></li>
|
||||||
|
|
||||||
<li><p>MUST NOT -- Use this operator when a
|
<li><p>MUST NOT — Use this operator when a
|
||||||
clause must not occur in the result set. No
|
clause must not occur in the result set. No
|
||||||
document in the result set will match
|
document in the result set will match
|
||||||
any such clauses.</p></li>
|
any such clauses.</p></li>
|
||||||
|
@ -100,18 +100,18 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
<h4>Phrases</h4>
|
<h4>Phrases</h4>
|
||||||
|
|
||||||
<p>Another common search is to find documents containing certain phrases. This
|
<p>Another common search is to find documents containing certain phrases. This
|
||||||
is handled in two different ways.
|
is handled two different ways:
|
||||||
<ol>
|
<ol>
|
||||||
<li>
|
<li>
|
||||||
<p><a href="PhraseQuery.html">PhraseQuery</a>
|
<p><a href="PhraseQuery.html">PhraseQuery</a>
|
||||||
-- Matches a sequence of
|
— Matches a sequence of
|
||||||
<a href="../index/Term.html">Terms</a>.
|
<a href="../index/Term.html">Terms</a>.
|
||||||
<a href="PhraseQuery.html">PhraseQuery</a> uses a slop factor to determine
|
<a href="PhraseQuery.html">PhraseQuery</a> uses a slop factor to determine
|
||||||
how many positions may occur between any two terms in the phrase and still be considered a match.</p>
|
how many positions may occur between any two terms in the phrase and still be considered a match.</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p><a href="spans/SpanNearQuery.html">SpanNearQuery</a>
|
<p><a href="spans/SpanNearQuery.html">SpanNearQuery</a>
|
||||||
-- Matches a sequence of other
|
— Matches a sequence of other
|
||||||
<a href="spans/SpanQuery.html">SpanQuery</a>
|
<a href="spans/SpanQuery.html">SpanQuery</a>
|
||||||
instances. <a href="spans/SpanNearQuery.html">SpanNearQuery</a> allows for
|
instances. <a href="spans/SpanNearQuery.html">SpanNearQuery</a> allows for
|
||||||
much more
|
much more
|
||||||
|
@ -203,15 +203,15 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
href="http://www.nabble.com/Overriding-Similarity-tf2128934.html">Overriding Similarity</a>.
|
href="http://www.nabble.com/Overriding-Similarity-tf2128934.html">Overriding Similarity</a>.
|
||||||
In summary, here are a few use cases:
|
In summary, here are a few use cases:
|
||||||
<ol>
|
<ol>
|
||||||
<li><p><a href="api/org/apache/lucene/misc/SweetSpotSimilarity.html">SweetSpotSimilarity</a> -- <a
|
<li><p><a href="api/org/apache/lucene/misc/SweetSpotSimilarity.html">SweetSpotSimilarity</a> — <a
|
||||||
href="api/org/apache/lucene/misc/SweetSpotSimilarity.html">SweetSpotSimilarity</a> gives small increases
|
href="api/org/apache/lucene/misc/SweetSpotSimilarity.html">SweetSpotSimilarity</a> gives small increases
|
||||||
as the frequency increases a small amount
|
as the frequency increases a small amount
|
||||||
and then greater increases when you hit the "sweet spot", i.e. where you think the frequency of terms is
|
and then greater increases when you hit the "sweet spot", i.e. where you think the frequency of terms is
|
||||||
more significant.</p></li>
|
more significant.</p></li>
|
||||||
<li><p>Overriding tf -- In some applications, it doesn't matter what the score of a document is as long as a
|
<li><p>Overriding tf — In some applications, it doesn't matter what the score of a document is as long as a
|
||||||
matching term occurs. In these
|
matching term occurs. In these
|
||||||
cases people have overridden Similarity to return 1 from the tf() method.</p></li>
|
cases people have overridden Similarity to return 1 from the tf() method.</p></li>
|
||||||
<li><p>Changing Length Normalization -- By overriding <a
|
<li><p>Changing Length Normalization — By overriding <a
|
||||||
href="Similarity.html#lengthNorm(java.lang.String,%20int)">lengthNorm</a>,
|
href="Similarity.html#lengthNorm(java.lang.String,%20int)">lengthNorm</a>,
|
||||||
it is possible to discount how the length of a field contributes
|
it is possible to discount how the length of a field contributes
|
||||||
to a score. In <a href="DefaultSimilarity.html">DefaultSimilarity</a>,
|
to a score. In <a href="DefaultSimilarity.html">DefaultSimilarity</a>,
|
||||||
|
@ -227,7 +227,7 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
Similarity method.</blockquote>
|
Similarity method.</blockquote>
|
||||||
</p>
|
</p>
|
||||||
<a name="scoring"></a>
|
<a name="scoring"></a>
|
||||||
<h2>Changing Scoring -- Expert Level</h2>
|
<h2>Changing Scoring — Expert Level</h2>
|
||||||
|
|
||||||
<p>Changing scoring is an expert level task, so tread carefully and be prepared to share your code if
|
<p>Changing scoring is an expert level task, so tread carefully and be prepared to share your code if
|
||||||
you want help.
|
you want help.
|
||||||
|
@ -238,16 +238,16 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
<span >three main classes</span>:
|
<span >three main classes</span>:
|
||||||
<ol>
|
<ol>
|
||||||
<li>
|
<li>
|
||||||
<a href="Query.html">Query</a> -- The abstract object representation of the
|
<a href="Query.html">Query</a> — The abstract object representation of the
|
||||||
user's information need.</li>
|
user's information need.</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Weight.html">Weight</a> -- The internal interface representation of
|
<a href="Weight.html">Weight</a> — The internal interface representation of
|
||||||
the user's Query, so that Query objects may be reused.</li>
|
the user's Query, so that Query objects may be reused.</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Scorer.html">Scorer</a> -- An abstract class containing common
|
<a href="Scorer.html">Scorer</a> — An abstract class containing common
|
||||||
functionality for scoring. Provides both scoring and explanation capabilities.</li>
|
functionality for scoring. Provides both scoring and explanation capabilities.</li>
|
||||||
</ol>
|
</ol>
|
||||||
Details on each of these classes, and their children can be found in the subsections below.
|
Details on each of these classes, and their children, can be found in the subsections below.
|
||||||
</p>
|
</p>
|
||||||
<h4>The Query Class</h4>
|
<h4>The Query Class</h4>
|
||||||
<p>In some sense, the
|
<p>In some sense, the
|
||||||
|
@ -259,13 +259,13 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
<a href="Query.html">Query</a> class has several methods that are important for
|
<a href="Query.html">Query</a> class has several methods that are important for
|
||||||
derived classes:
|
derived classes:
|
||||||
<ol>
|
<ol>
|
||||||
<li>createWeight(Searcher searcher) -- A
|
<li>createWeight(Searcher searcher) — A
|
||||||
<a href="Weight.html">Weight</a> is the internal representation of the
|
<a href="Weight.html">Weight</a> is the internal representation of the
|
||||||
Query, so each Query implementation must
|
Query, so each Query implementation must
|
||||||
provide an implementation of Weight. See the subsection on <a
|
provide an implementation of Weight. See the subsection on <a
|
||||||
href="#The Weight Interface">The Weight Interface</a> below for details on implementing the Weight
|
href="#The Weight Interface">The Weight Interface</a> below for details on implementing the Weight
|
||||||
interface.</li>
|
interface.</li>
|
||||||
<li>rewrite(IndexReader reader) -- Rewrites queries into primitive queries. Primitive queries are:
|
<li>rewrite(IndexReader reader) — Rewrites queries into primitive queries. Primitive queries are:
|
||||||
<a href="TermQuery.html">TermQuery</a>,
|
<a href="TermQuery.html">TermQuery</a>,
|
||||||
<a href="BooleanQuery.html">BooleanQuery</a>, <span
|
<a href="BooleanQuery.html">BooleanQuery</a>, <span
|
||||||
>OTHERS????</span></li>
|
>OTHERS????</span></li>
|
||||||
|
@ -277,26 +277,26 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
interface provides an internal representation of the Query so that it can be reused. Any
|
interface provides an internal representation of the Query so that it can be reused. Any
|
||||||
<a href="Searcher.html">Searcher</a>
|
<a href="Searcher.html">Searcher</a>
|
||||||
dependent state should be stored in the Weight implementation,
|
dependent state should be stored in the Weight implementation,
|
||||||
not in the Query class. The interface defines 6 methods that must be implemented:
|
not in the Query class. The interface defines six methods that must be implemented:
|
||||||
<ol>
|
<ol>
|
||||||
<li>
|
<li>
|
||||||
<a href="Weight.html#getQuery()">Weight#getQuery()</a> -- Pointer to the
|
<a href="Weight.html#getQuery()">Weight#getQuery()</a> — Pointer to the
|
||||||
Query that this Weight represents.</li>
|
Query that this Weight represents.</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Weight.html#getValue()">Weight#getValue()</a> -- The weight for
|
<a href="Weight.html#getValue()">Weight#getValue()</a> — The weight for
|
||||||
this Query. For example, the TermQuery.TermWeight value is
|
this Query. For example, the TermQuery.TermWeight value is
|
||||||
equal to the idf^2 * boost * queryNorm <!-- DOUBLE CHECK THIS --></li>
|
equal to the idf^2 * boost * queryNorm <!-- DOUBLE CHECK THIS --></li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Weight.html#sumOfSquaredWeights()">
|
<a href="Weight.html#sumOfSquaredWeights()">
|
||||||
Weight#sumOfSquaredWeights()</a> -- The sum of squared weights. Tor TermQuery, this is (idf *
|
Weight#sumOfSquaredWeights()</a> — The sum of squared weights. For TermQuery, this is (idf *
|
||||||
boost)^2</li>
|
boost)^2</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Weight.html#normalize(float)">
|
<a href="Weight.html#normalize(float)">
|
||||||
Weight#normalize(float)</a> -- Determine the query normalization factor. The query normalization may
|
Weight#normalize(float)</a> — Determine the query normalization factor. The query normalization may
|
||||||
allow for comparing scores between queries.</li>
|
allow for comparing scores between queries.</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Weight.html#scorer(IndexReader)">
|
<a href="Weight.html#scorer(IndexReader)">
|
||||||
Weight#scorer(IndexReader)</a> -- Construct a new
|
Weight#scorer(IndexReader)</a> — Construct a new
|
||||||
<a href="Scorer.html">Scorer</a>
|
<a href="Scorer.html">Scorer</a>
|
||||||
for this Weight. See
|
for this Weight. See
|
||||||
<a href="#The Scorer Class">The Scorer Class</a>
|
<a href="#The Scorer Class">The Scorer Class</a>
|
||||||
|
@ -305,7 +305,7 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Weight.html#explain(IndexReader, int)">
|
<a href="Weight.html#explain(IndexReader, int)">
|
||||||
Weight#explain(IndexReader, int)</a> -- Provide a means for explaining why a given document was
|
Weight#explain(IndexReader, int)</a> — Provide a means for explaining why a given document was
|
||||||
scored
|
scored
|
||||||
the way it was.</li>
|
the way it was.</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
@ -318,29 +318,29 @@ org.apache.lucene.search.Searcher#search(Query,Filter)}.
|
||||||
must be implemented:
|
must be implemented:
|
||||||
<ol>
|
<ol>
|
||||||
<li>
|
<li>
|
||||||
<a href="Scorer.html#next()">Scorer#next()</a> -- Advances to the next
|
<a href="Scorer.html#next()">Scorer#next()</a> — Advances to the next
|
||||||
document that matches this Query, returning true if and only
|
document that matches this Query, returning true if and only
|
||||||
if there is another document that matches.</li>
|
if there is another document that matches.</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Scorer.html#doc()">Scorer#doc()</a> -- Returns the id of the
|
<a href="Scorer.html#doc()">Scorer#doc()</a> — Returns the id of the
|
||||||
<a href="../document/Document.html">Document</a>
|
<a href="../document/Document.html">Document</a>
|
||||||
that contains the match. Is not valid until next() has been called at least once.
|
that contains the match. It is not valid until next() has been called at least once.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Scorer.html#score()">Scorer#score()</a> -- Return the score of the
|
<a href="Scorer.html#score()">Scorer#score()</a> — Return the score of the
|
||||||
current document. This value can be determined in any
|
current document. This value can be determined in any
|
||||||
appropriate way for an application. For instance, the
|
appropriate way for an application. For instance, the
|
||||||
<a href="http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java?view=log">TermScorer</a>
|
<a href="http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java?view=log">TermScorer</a>
|
||||||
returns the tf * Weight.getValue() * fieldNorm.
|
returns the tf * Weight.getValue() * fieldNorm.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Scorer.html#skipTo(int)">Scorer#skipTo(int)</a> -- Skip ahead in
|
<a href="Scorer.html#skipTo(int)">Scorer#skipTo(int)</a> — Skip ahead in
|
||||||
the document matches to the document whose id is greater than
|
the document matches to the document whose id is greater than
|
||||||
or equal to the passed in value. In many instances, skipTo can be
|
or equal to the passed in value. In many instances, skipTo can be
|
||||||
implemented more efficiently than simply looping through all the matching documents until
|
implemented more efficiently than simply looping through all the matching documents until
|
||||||
the target document is identified.</li>
|
the target document is identified.</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="Scorer.html#explain(int)">Scorer#explain(int)</a> -- Provides
|
<a href="Scorer.html#explain(int)">Scorer#explain(int)</a> — Provides
|
||||||
details on why the score came about.</li>
|
details on why the score came about.</li>
|
||||||
</ol>
|
</ol>
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue