You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by mi...@apache.org on 2009/06/23 20:11:43 UTC
svn commit: r787772 [2/2] - in /lucene/java/trunk: ./
contrib/miscellaneous/src/test/org/apache/lucene/index/
contrib/miscellaneous/src/test/org/apache/lucene/misc/
contrib/remote/src/java/org/apache/lucene/search/
src/java/org/apache/lucene/index/ src...
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/QueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/QueryWrapperFilter.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/QueryWrapperFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/QueryWrapperFilter.java Tue Jun 23 18:11:42 2009
@@ -61,15 +61,18 @@
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
return bits;
}
public DocIdSet getDocIdSet(final IndexReader reader) throws IOException {
- final Weight weight = query.weight(new IndexSearcher(reader));
+ final QueryWeight weight = query.queryWeight(new IndexSearcher(reader));
return new DocIdSet() {
public DocIdSetIterator iterator() throws IOException {
- return weight.scorer(reader);
+ return weight.scorer(reader, true, false);
}
};
}
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Searchable.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/Searchable.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Searchable.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Searchable.java Tue Jun 23 18:11:42 2009
@@ -17,25 +17,32 @@
* limitations under the License.
*/
+import java.io.IOException;
+
import org.apache.lucene.document.Document;
import org.apache.lucene.document.FieldSelector;
-import org.apache.lucene.index.IndexReader; // for javadoc
-import org.apache.lucene.index.Term;
import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.Term;
-import java.io.IOException; // for javadoc
-
-/** The interface for search implementations.
- *
- * <p>Searchable is the abstract network protocol for searching.
- * Implementations provide search over a single index, over multiple
- * indices, and over indices on remote servers.
- *
- * <p>Queries, filters and sort criteria are designed to be compact so that
- * they may be efficiently passed to a remote index, with only the top-scoring
- * hits being returned, rather than every matching hit.
+/**
+ * The interface for search implementations.
+ *
+ * <p>
+ * Searchable is the abstract network protocol for searching. Implementations
+ * provide search over a single index, over multiple indices, and over indices
+ * on remote servers.
+ *
+ * <p>
+ * Queries, filters and sort criteria are designed to be compact so that they
+ * may be efficiently passed to a remote index, with only the top-scoring hits
+ * being returned, rather than every matching hit.
+ *
+ * <b>NOTE:</b> this interface is kept public for convenience. Since it is not
+ * expected to be implemented directly, it may be changed unexpectedly between
+ * releases.
*/
public interface Searchable {
+
/** Lower-level search API.
*
* <p>{@link HitCollector#collect(int,float)} is called for every non-zero
@@ -51,7 +58,7 @@
* @param filter if non-null, used to permit documents to be collected.
* @param results to receive hits
* @throws BooleanQuery.TooManyClauses
- * @deprecated use {@link #search(Weight, Filter, Collector)} instead.
+ * @deprecated use {@link #search(QueryWeight, Filter, Collector)} instead.
*/
void search(Weight weight, Filter filter, HitCollector results)
throws IOException;
@@ -75,9 +82,33 @@
* @param collector
* to receive hits
* @throws BooleanQuery.TooManyClauses
+ *
+ * @deprecated use {@link #search(QueryWeight, Filter, Collector)} instead.
*/
void search(Weight weight, Filter filter, Collector collector) throws IOException;
+ /**
+ * Lower-level search API.
+ *
+ * <p>
+ * {@link Collector#collect(int)} is called for every document. <br>
+ * Collector-based access to remote indexes is discouraged.
+ *
+ * <p>
+ * Applications should only use this if they need <i>all</i> of the matching
+ * documents. The high-level search API ({@link Searcher#search(Query)}) is
+ * usually more efficient, as it skips non-high-scoring hits.
+ *
+ * @param weight
+ * to match documents
+ * @param filter
+ * if non-null, used to permit documents to be collected.
+ * @param collector
+ * to receive hits
+ * @throws BooleanQuery.TooManyClauses
+ */
+ void search(QueryWeight weight, Filter filter, Collector collector) throws IOException;
+
/** Frees resources associated with this Searcher.
* Be careful not to call this method while you are still using objects
* like {@link Hits}.
@@ -86,7 +117,7 @@
/** Expert: Returns the number of documents containing <code>term</code>.
* Called by search code to compute term weights.
- * @see IndexReader#docFreq(Term)
+ * @see org.apache.lucene.index.IndexReader#docFreq(Term)
*/
int docFreq(Term term) throws IOException;
@@ -98,7 +129,7 @@
/** Expert: Returns one greater than the largest possible document number.
* Called by search code to compute term weights.
- * @see IndexReader#maxDoc()
+ * @see org.apache.lucene.index.IndexReader#maxDoc()
*/
int maxDoc() throws IOException;
@@ -110,12 +141,24 @@
* <p>Applications should usually call {@link Searcher#search(Query)} or
* {@link Searcher#search(Query,Filter)} instead.
* @throws BooleanQuery.TooManyClauses
+ * @deprecated use {@link #search(QueryWeight, Filter, int)} instead.
*/
TopDocs search(Weight weight, Filter filter, int n) throws IOException;
+
+ /** Expert: Low-level search implementation. Finds the top <code>n</code>
+ * hits for <code>query</code>, applying <code>filter</code> if non-null.
+ *
+ * <p>Called by {@link Hits}.
+ *
+ * <p>Applications should usually call {@link Searcher#search(Query)} or
+ * {@link Searcher#search(Query,Filter)} instead.
+ * @throws BooleanQuery.TooManyClauses
+ */
+ TopDocs search(QueryWeight weight, Filter filter, int n) throws IOException;
/** Expert: Returns the stored fields of document <code>i</code>.
* Called by {@link HitCollector} implementations.
- * @see IndexReader#document(int)
+ * @see org.apache.lucene.index.IndexReader#document(int)
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if there is a low-level IO error
*/
@@ -136,7 +179,7 @@
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if there is a low-level IO error
*
- * @see IndexReader#document(int, FieldSelector)
+ * @see org.apache.lucene.index.IndexReader#document(int, FieldSelector)
* @see org.apache.lucene.document.Fieldable
* @see org.apache.lucene.document.FieldSelector
* @see org.apache.lucene.document.SetBasedFieldSelector
@@ -159,10 +202,23 @@
* entire index.
* <p>Applications should call {@link Searcher#explain(Query, int)}.
* @throws BooleanQuery.TooManyClauses
+ * @deprecated use {@link #explain(QueryWeight, int)} instead.
*/
Explanation explain(Weight weight, int doc) throws IOException;
+
+ /** Expert: low-level implementation method
+ * Returns an Explanation that describes how <code>doc</code> scored against
+ * <code>weight</code>.
+ *
+ * <p>This is intended to be used in developing Similarity implementations,
+ * and, for good performance, should not be displayed with every hit.
+ * Computing an explanation is as expensive as executing the query over the
+ * entire index.
+ * <p>Applications should call {@link Searcher#explain(Query, int)}.
+ * @throws BooleanQuery.TooManyClauses
+ */
+ Explanation explain(QueryWeight weight, int doc) throws IOException;
- // TODO: change the javadoc in 3.0 to remove the last NOTE section.
/** Expert: Low-level search implementation with arbitrary sorting. Finds
* the top <code>n</code> hits for <code>query</code>, applying
* <code>filter</code> if non-null, and sorting the hits by the criteria in
@@ -171,15 +227,23 @@
* <p>Applications should usually call {@link
* Searcher#search(Query,Filter,Sort)} instead.
*
- * <b>NOTE:</b> currently, this method tracks document scores and sets them in
- * the returned {@link FieldDoc}, however in 3.0 it will move to not track
- * document scores. If document scores tracking is still needed, you can use
- * {@link #search(Weight, Filter, Collector)} and pass in a
- * {@link TopFieldCollector} instance.
- *
* @throws BooleanQuery.TooManyClauses
+ * @deprecated use {@link #search(QueryWeight, Filter, int, Sort)} instead.
*/
TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort)
throws IOException;
+
+ /** Expert: Low-level search implementation with arbitrary sorting. Finds
+ * the top <code>n</code> hits for <code>query</code>, applying
+ * <code>filter</code> if non-null, and sorting the hits by the criteria in
+ * <code>sort</code>.
+ *
+ * <p>Applications should usually call {@link
+ * Searcher#search(Query,Filter,Sort)} instead.
+ *
+ * @throws BooleanQuery.TooManyClauses
+ */
+ TopFieldDocs search(QueryWeight weight, Filter filter, int n, Sort sort)
+ throws IOException;
}
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Searcher.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/Searcher.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Searcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Searcher.java Tue Jun 23 18:11:42 2009
@@ -19,15 +19,17 @@
import java.io.IOException;
+import org.apache.lucene.document.Document;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.Term;
-import org.apache.lucene.document.Document;
-/** An abstract base class for search implementations.
- * Implements the main search methods.
+/**
+ * An abstract base class for search implementations. Implements the main search
+ * methods.
*
- * <p>Note that you can only access Hits from a Searcher as long as it is
- * not yet closed, otherwise an IOException will be thrown.
+ * <p>
+ * Note that you can only access hits from a Searcher as long as it is not yet
+ * closed, otherwise an IOException will be thrown.
*/
public abstract class Searcher implements Searchable {
@@ -87,7 +89,7 @@
*/
public TopFieldDocs search(Query query, Filter filter, int n,
Sort sort) throws IOException {
- return search(createWeight(query), filter, n, sort);
+ return search(createQueryWeight(query), filter, n, sort);
}
/** Lower-level search API.
@@ -107,7 +109,7 @@
*/
public void search(Query query, HitCollector results)
throws IOException {
- search(query, (Filter)null, results);
+ search(createQueryWeight(query), null, new HitCollectorWrapper(results));
}
/** Lower-level search API.
@@ -125,7 +127,7 @@
*/
public void search(Query query, Collector results)
throws IOException {
- search(query, (Filter)null, results);
+ search(createQueryWeight(query), null, results);
}
/** Lower-level search API.
@@ -147,7 +149,7 @@
*/
public void search(Query query, Filter filter, HitCollector results)
throws IOException {
- search(createWeight(query), filter, results);
+ search(createQueryWeight(query), filter, new HitCollectorWrapper(results));
}
/** Lower-level search API.
@@ -168,7 +170,7 @@
*/
public void search(Query query, Filter filter, Collector results)
throws IOException {
- search(createWeight(query), filter, results);
+ search(createQueryWeight(query), filter, results);
}
/** Finds the top <code>n</code>
@@ -178,7 +180,7 @@
*/
public TopDocs search(Query query, Filter filter, int n)
throws IOException {
- return search(createWeight(query), filter, n);
+ return search(createQueryWeight(query), filter, n);
}
/** Finds the top <code>n</code>
@@ -200,7 +202,7 @@
* entire index.
*/
public Explanation explain(Query query, int doc) throws IOException {
- return explain(createWeight(query), doc);
+ return explain(createQueryWeight(query), doc);
}
/** The Similarity implementation used by this searcher. */
@@ -213,7 +215,7 @@
public void setSimilarity(Similarity similarity) {
this.similarity = similarity;
}
-
+
/** Expert: Return the Similarity implementation used by this Searcher.
*
* <p>This defaults to the current value of {@link Similarity#getDefault()}.
@@ -224,10 +226,15 @@
/**
* creates a weight for <code>query</code>
- * @return new weight
+ *
+ * @deprecated use {@link #createQueryWeight(Query)} instead.
*/
protected Weight createWeight(Query query) throws IOException {
- return query.weight(this);
+ return createQueryWeight(query);
+ }
+
+ protected QueryWeight createQueryWeight(Query query) throws IOException {
+ return query.queryWeight(this);
}
// inherit javadoc
@@ -245,15 +252,34 @@
/**
* @deprecated use {@link #search(Weight, Filter, Collector)} instead.
*/
- abstract public void search(Weight weight, Filter filter, HitCollector results) throws IOException;
- abstract public void search(Weight weight, Filter filter, Collector results) throws IOException;
+ public void search(Weight weight, Filter filter, HitCollector results) throws IOException {
+ search(new QueryWeightWrapper(weight), filter, new HitCollectorWrapper(results));
+ }
+ /** @deprecated delete in 3.0. */
+ public void search(Weight weight, Filter filter, Collector collector)
+ throws IOException {
+ search(new QueryWeightWrapper(weight), filter, collector);
+ }
+ abstract public void search(QueryWeight weight, Filter filter, Collector results) throws IOException;
abstract public void close() throws IOException;
abstract public int docFreq(Term term) throws IOException;
abstract public int maxDoc() throws IOException;
- abstract public TopDocs search(Weight weight, Filter filter, int n) throws IOException;
+ /** @deprecated use {@link #search(QueryWeight, Filter, int)} instead. */
+ public TopDocs search(Weight weight, Filter filter, int n) throws IOException {
+ return search(new QueryWeightWrapper(weight), filter, n);
+ }
+ abstract public TopDocs search(QueryWeight weight, Filter filter, int n) throws IOException;
abstract public Document doc(int i) throws CorruptIndexException, IOException;
abstract public Query rewrite(Query query) throws IOException;
- abstract public Explanation explain(Weight weight, int doc) throws IOException;
- abstract public TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort) throws IOException;
+ /** @deprecated use {@link #explain(QueryWeight, int)} instead. */
+ public Explanation explain(Weight weight, int doc) throws IOException {
+ return explain(new QueryWeightWrapper(weight), doc);
+ }
+ abstract public Explanation explain(QueryWeight weight, int doc) throws IOException;
+ /** @deprecated use {@link #search(QueryWeight, Filter, int, Sort)} instead. */
+ public TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort) throws IOException {
+ return search(new QueryWeightWrapper(weight), filter, n, sort);
+ }
+ abstract public TopFieldDocs search(QueryWeight weight, Filter filter, int n, Sort sort) throws IOException;
/* End patch for GCJ bug #15411. */
}
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/SloppyPhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/SloppyPhraseScorer.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/SloppyPhraseScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/SloppyPhraseScorer.java Tue Jun 23 18:11:42 2009
@@ -28,7 +28,7 @@
private PhrasePositions tmpPos[]; // for flipping repeating pps.
private boolean checkedRepeats;
- SloppyPhraseScorer(Weight weight, TermPositions[] tps, int[] offsets, Similarity similarity,
+ SloppyPhraseScorer(QueryWeight weight, TermPositions[] tps, int[] offsets, Similarity similarity,
int slop, byte[] norms) {
super(weight, tps, offsets, similarity, norms);
this.slop = slop;
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java Tue Jun 23 18:11:42 2009
@@ -31,7 +31,7 @@
public class TermQuery extends Query {
private Term term;
- private class TermWeight implements Weight {
+ private class TermWeight extends QueryWeight {
private Similarity similarity;
private float value;
private float idf;
@@ -60,14 +60,13 @@
value = queryWeight * idf; // idf for document
}
- public Scorer scorer(IndexReader reader) throws IOException {
+ public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
TermDocs termDocs = reader.termDocs(term);
if (termDocs == null)
return null;
- return new TermScorer(this, termDocs, similarity,
- reader.norms(term.field()));
+ return new TermScorer(this, termDocs, similarity, reader.norms(term.field()));
}
public Explanation explain(IndexReader reader, int doc)
@@ -104,7 +103,7 @@
fieldExpl.setDescription("fieldWeight("+term+" in "+doc+
"), product of:");
- Explanation tfExpl = scorer(reader).explain(doc);
+ Explanation tfExpl = scorer(reader, true, false).explain(doc);
fieldExpl.addDetail(tfExpl);
fieldExpl.addDetail(idfExpl);
@@ -142,7 +141,7 @@
/** Returns the term of this query. */
public Term getTerm() { return term; }
- protected Weight createWeight(Searcher searcher) throws IOException {
+ public QueryWeight createQueryWeight(Searcher searcher) throws IOException {
return new TermWeight(searcher);
}
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java Tue Jun 23 18:11:42 2009
@@ -27,7 +27,7 @@
private static final float[] SIM_NORM_DECODER = Similarity.getNormDecoder();
- private Weight weight;
+ private QueryWeight weight;
private TermDocs termDocs;
private byte[] norms;
private float weightValue;
@@ -41,13 +41,41 @@
private static final int SCORE_CACHE_SIZE = 32;
private float[] scoreCache = new float[SCORE_CACHE_SIZE];
- /** Construct a <code>TermScorer</code>.
- * @param weight The weight of the <code>Term</code> in the query.
- * @param td An iterator over the documents matching the <code>Term</code>.
- * @param similarity The </code>Similarity</code> implementation to be used for score computations.
- * @param norms The field norms of the document fields for the <code>Term</code>.
+ /**
+ * Construct a <code>TermScorer</code>.
+ *
+ * @param weight
+ * The weight of the <code>Term</code> in the query.
+ * @param td
+ * An iterator over the documents matching the <code>Term</code>.
+ * @param similarity
+ * The </code>Similarity</code> implementation to be used for score
+ * computations.
+ * @param norms
+ * The field norms of the document fields for the <code>Term</code>.
+ *
+ * @deprecated use delete in 3.0, kept around for TestTermScorer in tag which
+ * creates TermScorer directly, and cannot pass in a QueryWeight
+ * object.
+ */
+ TermScorer(Weight weight, TermDocs td, Similarity similarity, byte[] norms) {
+ this(new QueryWeightWrapper(weight), td, similarity, norms);
+ }
+
+ /**
+ * Construct a <code>TermScorer</code>.
+ *
+ * @param weight
+ * The weight of the <code>Term</code> in the query.
+ * @param td
+ * An iterator over the documents matching the <code>Term</code>.
+ * @param similarity
+ * The </code>Similarity</code> implementation to be used for score
+ * computations.
+ * @param norms
+ * The field norms of the document fields for the <code>Term</code>.
*/
- TermScorer(Weight weight, TermDocs td, Similarity similarity,
+ TermScorer(QueryWeight weight, TermDocs td, Similarity similarity,
byte[] norms) {
super(similarity);
this.weight = weight;
@@ -194,7 +222,7 @@
* @param doc The document number for the explanation.
*/
public Explanation explain(int doc) throws IOException {
- TermQuery query = (TermQuery)weight.getQuery();
+ TermQuery query = (TermQuery) weight.getQuery();
Explanation tfExplanation = new Explanation();
int tf = 0;
while (pointer < pointerMax) {
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TimeLimitingCollector.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TimeLimitingCollector.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TimeLimitingCollector.java Tue Jun 23 18:11:42 2009
@@ -216,4 +216,8 @@
collector.setScorer(scorer);
}
+ public boolean acceptsDocsOutOfOrder() {
+ return collector.acceptsDocsOutOfOrder();
+ }
+
}
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldCollector.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldCollector.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldCollector.java Tue Jun 23 18:11:42 2009
@@ -135,6 +135,11 @@
}
}
}
+
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
+
}
/*
@@ -240,6 +245,11 @@
}
}
}
+
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
+
}
/*
@@ -341,8 +351,12 @@
comparator.setBottom(bottom.slot);
}
}
-
}
+
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
+
}
/*
@@ -489,6 +503,11 @@
}
}
}
+
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
+
}
/*
@@ -632,6 +651,11 @@
}
}
}
+
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
+
}
/*
@@ -781,6 +805,11 @@
this.scorer = scorer;
super.setScorer(scorer);
}
+
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
+
}
private static final ScoreDoc[] EMPTY_SCOREDOCS = new ScoreDoc[0];
@@ -930,4 +959,8 @@
return new TopFieldDocs(totalHits, results, ((FieldValueHitQueue) pq).getFields(), maxScore);
}
+ public boolean acceptsDocsOutOfOrder() {
+ return false;
+ }
+
}
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TopScoreDocCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TopScoreDocCollector.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TopScoreDocCollector.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TopScoreDocCollector.java Tue Jun 23 18:11:42 2009
@@ -55,6 +55,10 @@
pqTop.score = score;
pqTop = (ScoreDoc) pq.updateTop();
}
+
+ public boolean acceptsDocsOutOfOrder() {
+ return false;
+ }
}
// Assumes docs are scored out of order.
@@ -74,6 +78,10 @@
pqTop.score = score;
pqTop = (ScoreDoc) pq.updateTop();
}
+
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
}
/**
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Weight.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/Weight.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Weight.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Weight.java Tue Jun 23 18:11:42 2009
@@ -40,6 +40,8 @@
* At this point the weighting is complete.
* <li>A <code>Scorer</code> is constructed by {@link #scorer(IndexReader)}.
* </ol>
+ *
+ * @deprecated use {@link QueryWeight} instead.
*/
public interface Weight extends java.io.Serializable {
/** The query that this concerns. */
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java Tue Jun 23 18:11:42 2009
@@ -24,10 +24,10 @@
import org.apache.lucene.search.ComplexExplanation;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.Query;
+import org.apache.lucene.search.QueryWeight;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.util.ToStringUtils;
/**
@@ -271,19 +271,18 @@
//=========================== W E I G H T ============================
- private class CustomWeight implements Weight {
+ private class CustomWeight extends QueryWeight {
Similarity similarity;
- Weight subQueryWeight;
- Weight[] valSrcWeights;
+ QueryWeight subQueryWeight;
+ QueryWeight[] valSrcWeights;
boolean qStrict;
public CustomWeight(Searcher searcher) throws IOException {
this.similarity = getSimilarity(searcher);
- this.subQueryWeight = subQuery.weight(searcher);
- this.subQueryWeight = subQuery.weight(searcher);
- this.valSrcWeights = new Weight[valSrcQueries.length];
+ this.subQueryWeight = subQuery.queryWeight(searcher);
+ this.valSrcWeights = new QueryWeight[valSrcQueries.length];
for(int i = 0; i < valSrcQueries.length; i++) {
- this.valSrcWeights[i] = valSrcQueries[i].createWeight(searcher);
+ this.valSrcWeights[i] = valSrcQueries[i].createQueryWeight(searcher);
}
this.qStrict = strict;
}
@@ -325,20 +324,28 @@
}
}
- /*(non-Javadoc) @see org.apache.lucene.search.Weight#scorer(org.apache.lucene.index.IndexReader) */
- public Scorer scorer(IndexReader reader) throws IOException {
- Scorer subQueryScorer = subQueryWeight.scorer(reader);
+ public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
+ // Pass true for "scoresDocsInOrder", because we
+ // require in-order scoring, even if caller does not,
+ // since we call advance on the valSrcScorers. Pass
+ // false for "topScorer" because we will not invoke
+ // score(Collector) on these scorers:
+ Scorer subQueryScorer = subQueryWeight.scorer(reader, true, false);
Scorer[] valSrcScorers = new Scorer[valSrcWeights.length];
for(int i = 0; i < valSrcScorers.length; i++) {
- valSrcScorers[i] = valSrcWeights[i].scorer(reader);
+ valSrcScorers[i] = valSrcWeights[i].scorer(reader, true, false);
}
return new CustomScorer(similarity, reader, this, subQueryScorer, valSrcScorers);
}
- /*(non-Javadoc) @see org.apache.lucene.search.Weight#explain(org.apache.lucene.index.IndexReader, int) */
public Explanation explain(IndexReader reader, int doc) throws IOException {
- return scorer(reader).explain(doc);
+ return scorer(reader, true, false).explain(doc);
}
+
+ public boolean scoresDocsOutOfOrder() {
+ return false;
+ }
+
}
@@ -435,8 +442,7 @@
}
}
- /*(non-Javadoc) @see org.apache.lucene.search.Query#createWeight(org.apache.lucene.search.Searcher) */
- protected Weight createWeight(Searcher searcher) throws IOException {
+ public QueryWeight createQueryWeight(Searcher searcher) throws IOException {
return new CustomWeight(searcher);
}
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java Tue Jun 23 18:11:42 2009
@@ -62,7 +62,7 @@
// no terms involved here
}
- private class ValueSourceWeight implements Weight {
+ private class ValueSourceWeight extends QueryWeight {
Similarity similarity;
float queryNorm;
float queryWeight;
@@ -93,14 +93,13 @@
queryWeight *= this.queryNorm;
}
- /*(non-Javadoc) @see org.apache.lucene.search.Weight#scorer(org.apache.lucene.index.IndexReader) */
- public Scorer scorer(IndexReader reader) throws IOException {
+ public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
return new ValueSourceScorer(similarity, reader, this);
}
/*(non-Javadoc) @see org.apache.lucene.search.Weight#explain(org.apache.lucene.index.IndexReader, int) */
public Explanation explain(IndexReader reader, int doc) throws IOException {
- return scorer(reader).explain(doc);
+ return scorer(reader, true, false).explain(doc);
}
}
@@ -173,12 +172,10 @@
}
}
- /*(non-Javadoc) @see org.apache.lucene.search.Query#createWeight(org.apache.lucene.search.Searcher) */
- protected Weight createWeight(Searcher searcher) {
+ public QueryWeight createQueryWeight(Searcher searcher) {
return new ValueSourceQuery.ValueSourceWeight(searcher);
}
- /* (non-Javadoc) @see org.apache.lucene.search.Query#toString(java.lang.String) */
public String toString(String field) {
return valSrc.toString() + ToStringUtils.boost(getBoost());
}
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java Tue Jun 23 18:11:42 2009
@@ -41,29 +41,23 @@
*/
public class BoostingTermQuery extends SpanTermQuery{
-
public BoostingTermQuery(Term term) {
super(term);
}
-
- protected Weight createWeight(Searcher searcher) throws IOException {
+ public QueryWeight createQueryWeight(Searcher searcher) throws IOException {
return new BoostingTermWeight(this, searcher);
}
- protected class BoostingTermWeight extends SpanWeight implements Weight {
-
+ protected class BoostingTermWeight extends SpanWeight {
public BoostingTermWeight(BoostingTermQuery query, Searcher searcher) throws IOException {
super(query, searcher);
}
-
-
-
- public Scorer scorer(IndexReader reader) throws IOException {
- return new BoostingSpanScorer((TermSpans)query.getSpans(reader), this, similarity,
- reader.norms(query.getField()));
+ public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
+ return new BoostingSpanScorer((TermSpans) query.getSpans(reader), this,
+ similarity, reader.norms(query.getField()));
}
protected class BoostingSpanScorer extends SpanScorer {
@@ -74,7 +68,7 @@
protected float payloadScore;
private int payloadsSeen;
- public BoostingSpanScorer(TermSpans spans, Weight weight,
+ public BoostingSpanScorer(TermSpans spans, QueryWeight weight,
Similarity similarity, byte[] norms) throws IOException {
super(spans, weight, similarity, norms);
positions = spans.getPositions();
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/FieldMaskingSpanQuery.java Tue Jun 23 18:11:42 2009
@@ -23,9 +23,9 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
+import org.apache.lucene.search.QueryWeight;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.util.ToStringUtils;
/**
@@ -97,6 +97,7 @@
return maskedQuery.getPayloadSpans(reader);
}
+ /** @deprecated use {@link #extractTerms(Set)} instead. */
public Collection getTerms() {
return maskedQuery.getTerms();
}
@@ -105,8 +106,8 @@
maskedQuery.extractTerms(terms);
}
- protected Weight createWeight(Searcher searcher) throws IOException {
- return maskedQuery.createWeight(searcher);
+ public QueryWeight createQueryWeight(Searcher searcher) throws IOException {
+ return maskedQuery.createQueryWeight(searcher);
}
public Similarity getSimilarity(Searcher searcher) {
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanQuery.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanQuery.java Tue Jun 23 18:11:42 2009
@@ -17,15 +17,15 @@
* limitations under the License.
*/
+import java.io.IOException;
+import java.util.Collection;
+
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
+import org.apache.lucene.search.QueryWeight;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.Weight;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Set;
-
/** Base class for span-based queries. */
public abstract class SpanQuery extends Query {
/** Expert: Returns the matches for this query in an index. Used internally
@@ -46,7 +46,7 @@
*/
public PayloadSpans getPayloadSpans(IndexReader reader) throws IOException{
return null;
- };
+ }
/** Returns the name of the field matched by this query.*/
public abstract String getField();
@@ -57,9 +57,13 @@
*/
public abstract Collection getTerms();
+ /** @deprecated delete in 3.0. */
protected Weight createWeight(Searcher searcher) throws IOException {
+ return createQueryWeight(searcher);
+ }
+
+ public QueryWeight createQueryWeight(Searcher searcher) throws IOException {
return new SpanWeight(this, searcher);
}
}
-
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanScorer.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanScorer.java Tue Jun 23 18:11:42 2009
@@ -17,19 +17,21 @@
* limitations under the License.
*/
+import java.io.IOException;
+
import org.apache.lucene.search.Explanation;
+import org.apache.lucene.search.QueryWeight;
+import org.apache.lucene.search.QueryWeightWrapper;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.Weight;
-import java.io.IOException;
-
/**
* Public for extension only.
*/
public class SpanScorer extends Scorer {
protected Spans spans;
- protected Weight weight;
+ protected QueryWeight weight;
protected byte[] norms;
protected float value;
@@ -40,8 +42,14 @@
protected int doc;
protected float freq;
+ /** @deprecated use {@link #SpanScorer(Spans, QueryWeight, Similarity, byte[])} instead.*/
protected SpanScorer(Spans spans, Weight weight, Similarity similarity, byte[] norms)
throws IOException {
+ this(spans, new QueryWeightWrapper(weight), similarity, norms);
+ }
+
+ protected SpanScorer(Spans spans, QueryWeight weight, Similarity similarity, byte[] norms)
+ throws IOException {
super(similarity);
this.spans = spans;
this.norms = norms;
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java Tue Jun 23 18:11:42 2009
@@ -29,7 +29,7 @@
/**
* Expert-only. Public for use by other weight implementations
*/
-public class SpanWeight implements Weight {
+public class SpanWeight extends QueryWeight {
protected Similarity similarity;
protected float value;
protected float idf;
@@ -63,10 +63,9 @@
value = queryWeight * idf; // idf for document
}
- public Scorer scorer(IndexReader reader) throws IOException {
- return new SpanScorer(query.getSpans(reader), this,
- similarity,
- reader.norms(query.getField()));
+ public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
+ return new SpanScorer(query.getSpans(reader), this, similarity, reader
+ .norms(query.getField()));
}
public Explanation explain(IndexReader reader, int doc)
@@ -115,7 +114,7 @@
fieldExpl.setDescription("fieldWeight("+field+":"+query.toString(field)+
" in "+doc+"), product of:");
- Explanation tfExpl = scorer(reader).explain(doc);
+ Explanation tfExpl = scorer(reader, true, false).explain(doc);
fieldExpl.addDetail(tfExpl);
fieldExpl.addDetail(idfExpl);
Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Tue Jun 23 18:11:42 2009
@@ -1073,7 +1073,6 @@
protected void setUp() throws Exception {
- // TODO Auto-generated method stub
super.setUp();
String tempDir = System.getProperty("java.io.tmpdir");
if (tempDir == null)
Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestOmitTf.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestOmitTf.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestOmitTf.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestOmitTf.java Tue Jun 23 18:11:42 2009
@@ -384,5 +384,8 @@
public void setNextReader(IndexReader reader, int docBase) {
this.docBase = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
}
}
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java Tue Jun 23 18:11:42 2009
@@ -17,15 +17,15 @@
* limitations under the License.
*/
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.index.IndexReader;
-
-import junit.framework.TestCase;
-
import java.io.IOException;
import java.util.Set;
import java.util.TreeSet;
+import junit.framework.Assert;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.store.Directory;
+
public class CheckHits {
/**
@@ -55,9 +55,9 @@
if (ignore.contains(new Integer(doc))) continue;
Explanation exp = searcher.explain(q, doc);
- TestCase.assertNotNull("Explanation of [["+d+"]] for #"+doc+" is null",
+ Assert.assertNotNull("Explanation of [["+d+"]] for #"+doc+" is null",
exp);
- TestCase.assertEquals("Explanation of [["+d+"]] for #"+doc+
+ Assert.assertEquals("Explanation of [["+d+"]] for #"+doc+
" doesn't indicate non-match: " + exp.toString(),
0.0f, exp.getValue(), 0.0f);
}
@@ -95,12 +95,14 @@
public void collect(int doc) {
actual.add(new Integer(doc + base));
}
-
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
- TestCase.assertEquals(query.toString(defaultFieldName), correct, actual);
+ Assert.assertEquals(query.toString(defaultFieldName), correct, actual);
QueryUtils.check(query,searcher);
}
@@ -126,7 +128,7 @@
int[] results)
throws IOException {
if (searcher instanceof IndexSearcher) {
- QueryUtils.check(query,(IndexSearcher)searcher);
+ QueryUtils.check(query,searcher);
}
ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
@@ -141,7 +143,7 @@
actual.add(new Integer(hits[i].doc));
}
- TestCase.assertEquals(query.toString(defaultFieldName), correct, actual);
+ Assert.assertEquals(query.toString(defaultFieldName), correct, actual);
QueryUtils.check(query,searcher);
}
@@ -149,9 +151,9 @@
/** Tests that a Hits has an expected order of documents */
public static void checkDocIds(String mes, int[] results, ScoreDoc[] hits)
throws IOException {
- TestCase.assertEquals(mes + " nr of hits", hits.length, results.length);
+ Assert.assertEquals(mes + " nr of hits", hits.length, results.length);
for (int i = 0; i < results.length; i++) {
- TestCase.assertEquals(mes + " doc nrs for hit " + i, results[i], hits[i].doc);
+ Assert.assertEquals(mes + " doc nrs for hit " + i, results[i], hits[i].doc);
}
}
@@ -173,11 +175,11 @@
public static void checkEqual(Query query, ScoreDoc[] hits1, ScoreDoc[] hits2) throws IOException {
final float scoreTolerance = 1.0e-6f;
if (hits1.length != hits2.length) {
- TestCase.fail("Unequal lengths: hits1="+hits1.length+",hits2="+hits2.length);
+ Assert.fail("Unequal lengths: hits1="+hits1.length+",hits2="+hits2.length);
}
for (int i = 0; i < hits1.length; i++) {
if (hits1[i].doc != hits2[i].doc) {
- TestCase.fail("Hit " + i + " docnumbers don't match\n"
+ Assert.fail("Hit " + i + " docnumbers don't match\n"
+ hits2str(hits1, hits2,0,0)
+ "for query:" + query.toString());
}
@@ -185,7 +187,7 @@
if ((hits1[i].doc != hits2[i].doc)
|| Math.abs(hits1[i].score - hits2[i].score) > scoreTolerance)
{
- TestCase.fail("Hit " + i + ", doc nrs " + hits1[i].doc + " and " + hits2[i].doc
+ Assert.fail("Hit " + i + ", doc nrs " + hits1[i].doc + " and " + hits2[i].doc
+ "\nunequal : " + hits1[i].score
+ "\n and: " + hits2[i].score
+ "\nfor query:" + query.toString());
@@ -294,7 +296,7 @@
boolean deep,
Explanation expl) {
float value = expl.getValue();
- TestCase.assertEquals(q+": score(doc="+doc+")="+score+
+ Assert.assertEquals(q+": score(doc="+doc+")="+score+
" != explanationScore="+value+" Explanation: "+expl,
score,value,EXPLAIN_SCORE_TOLERANCE_DELTA);
@@ -331,7 +333,7 @@
}
}
}
- TestCase.assertTrue(
+ Assert.assertTrue(
q+": multi valued explanation description=\""+descr
+"\" must be 'max of plus x times others' or end with 'product of'"
+" or 'sum of:' or 'max of:' - "+expl,
@@ -356,9 +358,9 @@
} else if (maxTimesOthers) {
combined = max + x * (sum - max);
} else {
- TestCase.assertTrue("should never get here!",false);
+ Assert.assertTrue("should never get here!",false);
}
- TestCase.assertEquals(q+": actual subDetails combined=="+combined+
+ Assert.assertEquals(q+": actual subDetails combined=="+combined+
" != value="+value+" Explanation: "+expl,
combined,value,EXPLAIN_SCORE_TOLERANCE_DELTA);
}
@@ -466,14 +468,15 @@
("exception in hitcollector of [["+d+"]] for #"+doc, e);
}
- TestCase.assertNotNull("Explanation of [["+d+"]] for #"+doc+" is null",
- exp);
+ Assert.assertNotNull("Explanation of [["+d+"]] for #"+doc+" is null", exp);
verifyExplanation(d,doc,scorer.score(),deep,exp);
}
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
-
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
}
}
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java Tue Jun 23 18:11:42 2009
@@ -38,22 +38,17 @@
private static final String UNSUPPORTED_MSG = "unsupported: used for back-compat testing only !";
- static final class JustCompileSearchable implements Searchable {
-
- public void close() throws IOException {
- throw new UnsupportedOperationException(UNSUPPORTED_MSG);
- }
+ static final class JustCompileSearcher extends Searcher {
- public Document doc(int i) throws CorruptIndexException, IOException {
+ protected QueryWeight createQueryWeight(Query query) throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
-
- public Document doc(int n, FieldSelector fieldSelector)
- throws CorruptIndexException, IOException {
+
+ public void close() throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public int docFreq(Term term) throws IOException {
+ public Document doc(int i) throws CorruptIndexException, IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
@@ -61,55 +56,45 @@
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public Explanation explain(Weight weight, int doc) throws IOException {
+ public Explanation explain(Query query, int doc) throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public int maxDoc() throws IOException {
- throw new UnsupportedOperationException(UNSUPPORTED_MSG);
- }
-
- public Query rewrite(Query query) throws IOException {
+ public Similarity getSimilarity() {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public void search(Weight weight, Filter filter, HitCollector results)
- throws IOException {
+ public void search(Query query, Collector results) throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public void search(Weight weight, Filter filter, Collector collector)
+ public void search(Query query, Filter filter, Collector results)
throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public TopDocs search(Weight weight, Filter filter, int n)
- throws IOException {
+ public TopDocs search(Query query, Filter filter, int n) throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
-
- public TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort)
+
+ public TopFieldDocs search(Query query, Filter filter, int n, Sort sort)
throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
-
- }
-
- static final class JustCompileSearcher extends Searcher {
-
- public void close() throws IOException {
+
+ public TopDocs search(Query query, int n) throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
-
- public Document doc(int i) throws CorruptIndexException, IOException {
+
+ public void setSimilarity(Similarity similarity) {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
-
+
public int docFreq(Term term) throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public Explanation explain(Weight weight, int doc) throws IOException {
+ public Explanation explain(QueryWeight weight, int doc) throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
@@ -121,22 +106,17 @@
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public void search(Weight weight, Filter filter, HitCollector results)
- throws IOException {
- throw new UnsupportedOperationException(UNSUPPORTED_MSG);
- }
-
- public void search(Weight weight, Filter filter, Collector results)
+ public void search(QueryWeight weight, Filter filter, Collector results)
throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public TopDocs search(Weight weight, Filter filter, int n)
+ public TopDocs search(QueryWeight weight, Filter filter, int n)
throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- public TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort)
+ public TopFieldDocs search(QueryWeight weight, Filter filter, int n, Sort sort)
throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
@@ -163,6 +143,10 @@
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
+ public boolean acceptsDocsOutOfOrder() {
+ throw new UnsupportedOperationException(UNSUPPORTED_MSG);
+ }
+
}
static final class JustCompileDocIdSet extends DocIdSet {
@@ -316,7 +300,7 @@
static final class JustCompilePhraseScorer extends PhraseScorer {
- JustCompilePhraseScorer(Weight weight, TermPositions[] tps, int[] offsets,
+ JustCompilePhraseScorer(QueryWeight weight, TermPositions[] tps, int[] offsets,
Similarity similarity, byte[] norms) {
super(weight, tps, offsets, similarity, norms);
}
@@ -437,9 +421,13 @@
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
+ public boolean acceptsDocsOutOfOrder() {
+ throw new UnsupportedOperationException(UNSUPPORTED_MSG);
+ }
+
}
- static final class JustCompileWeight implements Weight {
+ static final class JustCompileWeight extends QueryWeight {
public Explanation explain(IndexReader reader, int doc) throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
@@ -457,6 +445,7 @@
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
+ /** @deprecated delete in 3.0 */
public Scorer scorer(IndexReader reader) throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
@@ -464,6 +453,11 @@
public float sumOfSquaredWeights() throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
+
+ public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
+ throws IOException {
+ throw new UnsupportedOperationException(UNSUPPORTED_MSG);
+ }
}
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/QueryUtils.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/QueryUtils.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/QueryUtils.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/QueryUtils.java Tue Jun 23 18:11:42 2009
@@ -105,7 +105,7 @@
* @throws IOException if serialization check fail.
*/
private static void checkSerialization(Query q, Searcher s) throws IOException {
- Weight w = q.weight(s);
+ QueryWeight w = q.queryWeight(s);
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
@@ -150,8 +150,8 @@
//System.out.print("Order:");for (int i = 0; i < order.length; i++) System.out.print(order[i]==skip_op ? " skip()":" next()"); System.out.println();
final int opidx[] = {0};
- final Weight w = q.weight(s);
- final Scorer scorer = w.scorer(s.getIndexReader());
+ final QueryWeight w = q.queryWeight(s);
+ final Scorer scorer = w.scorer(s.getIndexReader(), true, false);
// FUTURE: ensure scorer.doc()==-1
@@ -200,6 +200,9 @@
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
// make sure next call to scorer is false.
@@ -228,8 +231,8 @@
float score = scorer.score();
try {
for (int i=lastDoc[0]+1; i<=doc; i++) {
- Weight w = q.weight(s);
- Scorer scorer = w.scorer(s.getIndexReader());
+ QueryWeight w = q.queryWeight(s);
+ Scorer scorer = w.scorer(s.getIndexReader(), true, false);
Assert.assertTrue("query collected "+doc+" but skipTo("+i+") says no more docs!",scorer.advance(i) != DocIdSetIterator.NO_MORE_DOCS);
Assert.assertEquals("query collected "+doc+" but skipTo("+i+") got to "+scorer.docID(),doc,scorer.docID());
float skipToScore = scorer.score();
@@ -244,9 +247,12 @@
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return false;
+ }
});
- Weight w = q.weight(s);
- Scorer scorer = w.scorer(s.getIndexReader());
+ QueryWeight w = q.queryWeight(s);
+ Scorer scorer = w.scorer(s.getIndexReader(), true, false);
boolean more = scorer.advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
if (more)
Assert.assertFalse("query's last doc was "+lastDoc[0]+" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.docID(),more);
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java Tue Jun 23 18:11:42 2009
@@ -122,9 +122,8 @@
new SortField("publicationDate_"),
SortField.FIELD_SCORE
});
- Searcher searcher =
- new MultiSearcher(new Searchable[] {
- new CustomSearcher (index, 2)});
+ Searcher searcher = new MultiSearcher(new Searcher[] { new CustomSearcher(
+ index, 2) });
// search and check hits
matchHits(searcher, custSort);
}
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java Tue Jun 23 18:11:42 2009
@@ -134,8 +134,8 @@
QueryUtils.check(dq,s);
- final Weight dw = dq.weight(s);
- final Scorer ds = dw.scorer(r);
+ final QueryWeight dw = dq.queryWeight(s);
+ final Scorer ds = dw.scorer(r, true, false);
final boolean skipOk = ds.advance(3) != DocIdSetIterator.NO_MORE_DOCS;
if (skipOk) {
fail("firsttime skipTo found a match? ... " + r.document(ds.docID()).get("id"));
@@ -149,40 +149,37 @@
QueryUtils.check(dq,s);
- final Weight dw = dq.weight(s);
- final Scorer ds = dw.scorer(r);
+ final QueryWeight dw = dq.queryWeight(s);
+ final Scorer ds = dw.scorer(r, true, false);
assertTrue("firsttime skipTo found no match", ds.advance(3) != DocIdSetIterator.NO_MORE_DOCS);
assertEquals("found wrong docid", "d4", r.document(ds.docID()).get("id"));
}
+ public void testSimpleEqualScores1() throws Exception {
-
- public void testSimpleEqualScores1() throws Exception {
-
- DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.0f);
- q.add(tq("hed","albino"));
- q.add(tq("hed","elephant"));
- QueryUtils.check(q,s);
-
- ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
-
- try {
- assertEquals("all docs should match " + q.toString(),
- 4, h.length);
-
- float score = h[0].score;
- for (int i = 1; i < h.length; i++) {
- assertEquals("score #" + i + " is not the same",
- score, h[i].score, SCORE_COMP_THRESH);
- }
- } catch (Error e) {
- printHits("testSimpleEqualScores1",h,s);
- throw e;
- }
-
-
+ DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.0f);
+ q.add(tq("hed","albino"));
+ q.add(tq("hed","elephant"));
+ QueryUtils.check(q,s);
+
+ ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
+
+ try {
+ assertEquals("all docs should match " + q.toString(),
+ 4, h.length);
+
+ float score = h[0].score;
+ for (int i = 1; i < h.length; i++) {
+ assertEquals("score #" + i + " is not the same",
+ score, h[i].score, SCORE_COMP_THRESH);
+ }
+ } catch (Error e) {
+ printHits("testSimpleEqualScores1",h,s);
+ throw e;
}
+ }
+
public void testSimpleEqualScores2() throws Exception {
DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.0f);
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestDocBoost.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestDocBoost.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestDocBoost.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestDocBoost.java Tue Jun 23 18:11:42 2009
@@ -80,6 +80,9 @@
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
float lastScore = 0.0f;
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java Tue Jun 23 18:11:42 2009
@@ -180,6 +180,9 @@
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
//
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java Tue Jun 23 18:11:42 2009
@@ -99,6 +99,10 @@
this.scorer = new ScoreCachingWrappingScorer(scorer);
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
+
}
private static final float[] scores = new float[] { 0.7767749f, 1.7839992f,
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java Tue Jun 23 18:11:42 2009
@@ -114,6 +114,9 @@
public void setNextReader(IndexReader reader, int base) {
docBase = base;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
}
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSetNorm.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestSetNorm.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestSetNorm.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestSetNorm.java Tue Jun 23 18:11:42 2009
@@ -76,6 +76,9 @@
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
float lastScore = 0.0f;
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestSimilarity.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestSimilarity.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestSimilarity.java Tue Jun 23 18:11:42 2009
@@ -74,9 +74,7 @@
Term b = new Term("field", "b");
Term c = new Term("field", "c");
- searcher.search
- (new TermQuery(b),
- new Collector() {
+ searcher.search(new TermQuery(b), new Collector() {
private Scorer scorer;
public void setScorer(Scorer scorer) throws IOException {
this.scorer = scorer;
@@ -85,15 +83,16 @@
assertTrue(scorer.score() == 1.0f);
}
public void setNextReader(IndexReader reader, int docBase) {}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(a), BooleanClause.Occur.SHOULD);
bq.add(new TermQuery(b), BooleanClause.Occur.SHOULD);
//System.out.println(bq.toString("field"));
- searcher.search
- (bq,
- new Collector() {
+ searcher.search(bq, new Collector() {
private int base = 0;
private Scorer scorer;
public void setScorer(Scorer scorer) throws IOException {
@@ -106,6 +105,9 @@
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
PhraseQuery pq = new PhraseQuery();
@@ -124,13 +126,14 @@
assertTrue(scorer.score() == 1.0f);
}
public void setNextReader(IndexReader reader, int docBase) {}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
pq.setSlop(2);
//System.out.println(pq.toString("field"));
- searcher.search
- (pq,
- new Collector() {
+ searcher.search(pq, new Collector() {
private Scorer scorer;
public void setScorer(Scorer scorer) throws IOException {
this.scorer = scorer;
@@ -140,6 +143,9 @@
assertTrue(scorer.score() == 2.0f);
}
public void setNextReader(IndexReader reader, int docBase) {}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
}
}
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java Tue Jun 23 18:11:42 2009
@@ -70,7 +70,7 @@
Term allTerm = new Term(FIELD, "all");
TermQuery termQuery = new TermQuery(allTerm);
- Weight weight = termQuery.weight(indexSearcher);
+ QueryWeight weight = termQuery.queryWeight(indexSearcher);
TermScorer ts = new TermScorer(weight,
indexReader.termDocs(allTerm), indexSearcher.getSimilarity(),
@@ -98,6 +98,9 @@
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
});
assertTrue("docs Size: " + docs.size() + " is not: " + 2, docs.size() == 2);
TestHit doc0 = (TestHit) docs.get(0);
@@ -129,7 +132,7 @@
Term allTerm = new Term(FIELD, "all");
TermQuery termQuery = new TermQuery(allTerm);
- Weight weight = termQuery.weight(indexSearcher);
+ QueryWeight weight = termQuery.queryWeight(indexSearcher);
TermScorer ts = new TermScorer(weight,
indexReader.termDocs(allTerm), indexSearcher.getSimilarity(),
@@ -146,14 +149,14 @@
Term allTerm = new Term(FIELD, "all");
TermQuery termQuery = new TermQuery(allTerm);
- Weight weight = termQuery.weight(indexSearcher);
+ QueryWeight weight = termQuery.queryWeight(indexSearcher);
TermScorer ts = new TermScorer(weight,
indexReader.termDocs(allTerm), indexSearcher.getSimilarity(),
indexReader.norms(FIELD));
assertTrue("Didn't skip", ts.advance(3) != DocIdSetIterator.NO_MORE_DOCS);
//The next doc should be doc 5
- assertTrue("doc should be number 5", ts.doc() == 5);
+ assertTrue("doc should be number 5", ts.docID() == 5);
}
public void testExplain() throws Exception
@@ -161,7 +164,7 @@
Term allTerm = new Term(FIELD, "all");
TermQuery termQuery = new TermQuery(allTerm);
- Weight weight = termQuery.weight(indexSearcher);
+ QueryWeight weight = termQuery.queryWeight(indexSearcher);
TermScorer ts = new TermScorer(weight,
indexReader.termDocs(allTerm), indexSearcher.getSimilarity(),
@@ -179,7 +182,7 @@
Term dogsTerm = new Term(FIELD, "dogs");
termQuery = new TermQuery(dogsTerm);
- weight = termQuery.weight(indexSearcher);
+ weight = termQuery.queryWeight(indexSearcher);
ts = new TermScorer(weight, indexReader.termDocs(dogsTerm), indexSearcher.getSimilarity(),
indexReader.norms(FIELD));
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Tue Jun 23 18:11:42 2009
@@ -332,6 +332,10 @@
docBase = base;
}
+ public boolean acceptsDocsOutOfOrder() {
+ return false;
+ }
+
}
}
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTopDocsCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTopDocsCollector.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTopDocsCollector.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTopDocsCollector.java Tue Jun 23 18:11:42 2009
@@ -69,6 +69,10 @@
// Don't do anything. Assign scores in random
}
+ public boolean acceptsDocsOutOfOrder() {
+ return true;
+ }
+
}
// Scores array to be used by MyTopDocsCollector. If it is changed, MAX_SCORE
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java Tue Jun 23 18:11:42 2009
@@ -21,6 +21,7 @@
import java.util.Collection;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.QueryWeight;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.Weight;
@@ -69,6 +70,7 @@
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
+ /** @deprecated delete in 3.0. */
public Collection getTerms() {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
@@ -113,10 +115,16 @@
static final class JustCompileSpanScorer extends SpanScorer {
+ /** @deprecated delete in 3.0 */
protected JustCompileSpanScorer(Spans spans, Weight weight,
Similarity similarity, byte[] norms) throws IOException {
super(spans, weight, similarity, norms);
}
+
+ protected JustCompileSpanScorer(Spans spans, QueryWeight weight,
+ Similarity similarity, byte[] norms) throws IOException {
+ super(spans, weight, similarity, norms);
+ }
protected boolean setFreqCurrentDoc() throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java?rev=787772&r1=787771&r2=787772&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java Tue Jun 23 18:11:42 2009
@@ -17,23 +17,18 @@
* limitations under the License.
*/
-import org.apache.lucene.search.Explanation;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.Weight;
-import org.apache.lucene.search.CheckHits;
-import org.apache.lucene.store.RAMDirectory;
-
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.Term;
-
import org.apache.lucene.analysis.WhitespaceAnalyzer;
-
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.QueryParser;
-
+import org.apache.lucene.search.CheckHits;
+import org.apache.lucene.search.Explanation;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.QueryWeight;
+import org.apache.lucene.search.Scorer;
+import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
public class TestNearSpansOrdered extends LuceneTestCase {
@@ -163,8 +158,8 @@
*/
public void testSpanNearScorerSkipTo1() throws Exception {
SpanNearQuery q = makeQuery();
- Weight w = q.createWeight(searcher);
- Scorer s = w.scorer(searcher.getIndexReader());
+ QueryWeight w = q.queryWeight(searcher);
+ Scorer s = w.scorer(searcher.getIndexReader(), true, false);
assertEquals(1, s.advance(1));
}
/**
@@ -173,8 +168,8 @@
*/
public void testSpanNearScorerExplain() throws Exception {
SpanNearQuery q = makeQuery();
- Weight w = q.createWeight(searcher);
- Scorer s = w.scorer(searcher.getIndexReader());
+ QueryWeight w = q.queryWeight(searcher);
+ Scorer s = w.scorer(searcher.getIndexReader(), true, false);
Explanation e = s.explain(1);
assertTrue("Scorer explanation value for doc#1 isn't positive: "
+ e.toString(),