this class is very similar to Lucene.Net.Search.Spans.SpanTermQuery except that it factors in the value of the payload located at each of the positions where the Lucene.Net.Index.Term occurs.

NOTE: In order to take advantage of this with the default scoring implementation (DefaultSimilarity), you must override DefaultSimilarity#scorePayload(int, int, int, BytesRef), which returns 1 by default.

Payload scores are aggregated using a pluggable PayloadFunction.

Inheritance: Lucene.Net.Search.Spans.SpanTermQuery
Exemple #1
0
        public virtual void Test()
        {
            PayloadTermQuery query = new PayloadTermQuery(new Term("field", "seventy"), new MaxPayloadFunction());
            TopDocs          hits  = Searcher.Search(query, null, 100);

            Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
            Assert.IsTrue(hits.TotalHits == 100, "hits Size: " + hits.TotalHits + " is not: " + 100);

            //they should all have the exact same score, because they all contain seventy once, and we set
            //all the other similarity factors to be 1

            Assert.IsTrue(hits.MaxScore == 1, hits.MaxScore + " does not equal: " + 1);
            for (int i = 0; i < hits.ScoreDocs.Length; i++)
            {
                ScoreDoc doc = hits.ScoreDocs[i];
                Assert.IsTrue(doc.Score == 1, doc.Score + " does not equal: " + 1);
            }
            CheckHits.CheckExplanations(query, PayloadHelper.FIELD, Searcher, true);
            Spans spans = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, query);

            Assert.IsTrue(spans != null, "spans is null and it shouldn't be");

            /*float score = hits.Score(0);
             * for (int i =1; i < hits.Length(); i++)
             * {
             * Assert.IsTrue(score == hits.Score(i), "scores are not equal and they should be");
             * }*/
        }
Exemple #2
0
        public virtual void  Test()
        {
            PayloadTermQuery query = new PayloadTermQuery(new Term("field", "seventy"), new MaxPayloadFunction());
            TopDocs          hits  = searcher.Search(query, null, 100);

            Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
            Assert.IsTrue(hits.TotalHits == 100, "hits Size: " + hits.TotalHits + " is not: " + 100);

            //they should all have the exact same score, because they all contain seventy once, and we set
            //all the other similarity factors to be 1

            Assert.IsTrue(hits.GetMaxScore() == 1, hits.GetMaxScore() + " does not equal: " + 1);
            for (int i = 0; i < hits.ScoreDocs.Length; i++)
            {
                ScoreDoc doc = hits.ScoreDocs[i];
                Assert.IsTrue(doc.score == 1, doc.score + " does not equal: " + 1);
            }
            CheckHits.CheckExplanations(query, PayloadHelper.FIELD, searcher, true);
            Lucene.Net.Search.Spans.Spans spans = query.GetSpans(searcher.GetIndexReader());
            Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
            Assert.IsTrue(spans is TermSpans, "spans is not an instanceof " + typeof(TermSpans));

            /*float score = hits.score(0);
             * for (int i =1; i < hits.length(); i++)
             * {
             * Assert.IsTrue(score == hits.score(i), "scores are not equal and they should be");
             * }*/
        }
Exemple #3
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            PayloadTermQuery other = (PayloadTermQuery)obj;

            if (Function == null)
            {
                if (other.Function != null)
                {
                    return(false);
                }
            }
            else if (!Function.Equals(other.Function))
            {
                return(false);
            }
            if (IncludeSpanScore != other.IncludeSpanScore)
            {
                return(false);
            }
            return(true);
        }
Exemple #4
0
        public virtual void TestNoMatch()
        {
            PayloadTermQuery query = new PayloadTermQuery(new Term(PayloadHelper.FIELD, "junk"), new MaxPayloadFunction());
            TopDocs          hits  = Searcher.Search(query, null, 100);

            Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
            Assert.IsTrue(hits.TotalHits == 0, "hits Size: " + hits.TotalHits + " is not: " + 0);
        }
        public override SpanQuery GetSpanQuery(XmlElement e)
        {
            string fieldName = DOMUtils.GetAttributeWithInheritanceOrFail(e, "fieldName");
            string value = DOMUtils.GetNonBlankTextOrFail(e);

            PayloadTermQuery btq = new PayloadTermQuery(new Term(fieldName, value), new AveragePayloadFunction());
            btq.Boost = DOMUtils.GetAttribute(e, "boost", 1.0f);
            return btq;
        }
 private SpanNearQuery SpanNearQuery(string fieldName, string words)
 {
     string[]    wordList = words.Split("[\\s]+".ToCharArray());
     SpanQuery[] clauses  = new SpanQuery[wordList.Length];
     for (int i = 0; i < clauses.Length; i++)
     {
         clauses[i] = new PayloadTermQuery(new Term(fieldName, wordList[i]), new AveragePayloadFunction());
     }
     return(new SpanNearQuery(clauses, 10000, false));
 }
Exemple #7
0
 private SpanNearQuery SpanNearQuery_Renamed(System.String fieldName, System.String words)
 {
     System.String[] wordList = System.Text.RegularExpressions.Regex.Split(words, "[\\s]+");
     SpanQuery[]     clauses  = new SpanQuery[wordList.Length];
     for (int i = 0; i < clauses.Length; i++)
     {
         clauses[i] = new PayloadTermQuery(new Term(fieldName, wordList[i]), new AveragePayloadFunction());
     }
     return(new SpanNearQuery(clauses, 10000, false));
 }
        private SpanNearQuery SpanNearQuery(string fieldName, string words)
        {
            var wordList = _whiteSpaceRegex.Split(words);
            var clauses  = new SpanQuery[wordList.Length];

            for (var i = 0; i < clauses.Length; i++)
            {
                clauses[i] = new PayloadTermQuery(new Term(fieldName, wordList[i]), new AveragePayloadFunction());
            }
            return(new SpanNearQuery(clauses, 10000, false));
        }
Exemple #9
0
        private PayloadNearQuery NewPhraseQuery(System.String fieldName, System.String phrase, bool inOrder)
        {
            int n;

            System.String[] words   = System.Text.RegularExpressions.Regex.Split(phrase, "[\\s]+");
            SpanQuery[]     clauses = new SpanQuery[words.Length];
            for (int i = 0; i < clauses.Length; i++)
            {
                clauses[i] = new PayloadTermQuery(new Term(fieldName, words[i]), new AveragePayloadFunction());
            }
            return(new PayloadNearQuery(clauses, 0, inOrder));
        }
Exemple #10
0
        public virtual void TestQuery()
        {
            PayloadTermQuery boostingFuncTermQuery = new PayloadTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"), new MaxPayloadFunction());

            QueryUtils.Check(boostingFuncTermQuery);

            SpanTermQuery spanTermQuery = new SpanTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"));

            Assert.IsTrue(boostingFuncTermQuery.Equals(spanTermQuery) == spanTermQuery.Equals(boostingFuncTermQuery));

            PayloadTermQuery boostingFuncTermQuery2 = new PayloadTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"), new AveragePayloadFunction());

            QueryUtils.CheckUnequal(boostingFuncTermQuery, boostingFuncTermQuery2);
        }
Exemple #11
0
        public virtual void TestIgnoreSpanScorer()
        {
            PayloadTermQuery query = new PayloadTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"), new MaxPayloadFunction(), false);

            IndexReader   reader      = DirectoryReader.Open(Directory);
            IndexSearcher theSearcher = NewSearcher(reader);

            theSearcher.Similarity = new FullSimilarity();
            TopDocs hits = Searcher.Search(query, null, 100);

            Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
            Assert.IsTrue(hits.TotalHits == 100, "hits Size: " + hits.TotalHits + " is not: " + 100);

            //they should all have the exact same score, because they all contain seventy once, and we set
            //all the other similarity factors to be 1

            //System.out.println("Hash: " + seventyHash + " Twice Hash: " + 2*seventyHash);
            Assert.IsTrue(hits.MaxScore == 4.0, hits.MaxScore + " does not equal: " + 4.0);
            //there should be exactly 10 items that score a 4, all the rest should score a 2
            //The 10 items are: 70 + i*100 where i in [0-9]
            int numTens = 0;

            for (int i = 0; i < hits.ScoreDocs.Length; i++)
            {
                ScoreDoc doc = hits.ScoreDocs[i];
                if (doc.Doc % 10 == 0)
                {
                    numTens++;
                    Assert.IsTrue(doc.Score == 4.0, doc.Score + " does not equal: " + 4.0);
                }
                else
                {
                    Assert.IsTrue(doc.Score == 2, doc.Score + " does not equal: " + 2);
                }
            }
            Assert.IsTrue(numTens == 10, numTens + " does not equal: " + 10);
            CheckHits.CheckExplanations(query, "field", Searcher, true);
            Spans spans = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, query);

            Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
            //should be two matches per document
            int count = 0;

            //100 hits times 2 matches per hit, we should have 200 in count
            while (spans.Next())
            {
                count++;
            }
            reader.Dispose();
        }
        public virtual void  TestMultipleMatchesPerDoc()
        {
            PayloadTermQuery query = new PayloadTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"), new MaxPayloadFunction());
            TopDocs          hits  = searcher.Search(query, null, 100, null);

            Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
            Assert.IsTrue(hits.TotalHits == 100, "hits Size: " + hits.TotalHits + " is not: " + 100);

            //they should all have the exact same score, because they all contain seventy once, and we set
            //all the other similarity factors to be 1

            //System.out.println("Hash: " + seventyHash + " Twice Hash: " + 2*seventyHash);
            Assert.IsTrue(hits.MaxScore == 4.0, hits.MaxScore + " does not equal: " + 4.0);
            //there should be exactly 10 items that score a 4, all the rest should score a 2
            //The 10 items are: 70 + i*100 where i in [0-9]
            int numTens = 0;

            for (int i = 0; i < hits.ScoreDocs.Length; i++)
            {
                ScoreDoc doc = hits.ScoreDocs[i];
                if (doc.Doc % 10 == 0)
                {
                    numTens++;
                    Assert.IsTrue(doc.Score == 4.0, doc.Score + " does not equal: " + 4.0);
                }
                else
                {
                    Assert.IsTrue(doc.Score == 2, doc.Score + " does not equal: " + 2);
                }
            }
            Assert.IsTrue(numTens == 10, numTens + " does not equal: " + 10);
            CheckHits.CheckExplanations(query, "field", searcher, true);
            Lucene.Net.Search.Spans.Spans spans = query.GetSpans(searcher.IndexReader, null);
            Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
            Assert.IsTrue(spans is TermSpans, "spans is not an instanceof " + typeof(TermSpans));
            //should be two matches per document
            int count = 0;

            //100 hits times 2 matches per hit, we should have 200 in count
            while (spans.Next(null))
            {
                count++;
            }
            Assert.IsTrue(count == 200, count + " does not equal: " + 200);
        }
Exemple #13
0
        public virtual void TestNoPayload()
        {
            PayloadTermQuery q1    = new PayloadTermQuery(new Term(PayloadHelper.NO_PAYLOAD_FIELD, "zero"), new MaxPayloadFunction());
            PayloadTermQuery q2    = new PayloadTermQuery(new Term(PayloadHelper.NO_PAYLOAD_FIELD, "foo"), new MaxPayloadFunction());
            BooleanClause    c1    = new BooleanClause(q1, BooleanClause.Occur.MUST);
            BooleanClause    c2    = new BooleanClause(q2, BooleanClause.Occur.MUST_NOT);
            BooleanQuery     query = new BooleanQuery();

            query.Add(c1);
            query.Add(c2);
            TopDocs hits = Searcher.Search(query, null, 100);

            Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
            Assert.IsTrue(hits.TotalHits == 1, "hits Size: " + hits.TotalHits + " is not: " + 1);
            int[] results = new int[1];
            results[0] = 0; //hits.ScoreDocs[0].Doc;
            CheckHits.CheckHitCollector(Random(), query, PayloadHelper.NO_PAYLOAD_FIELD, Searcher, results);
        }
 public PayloadTermWeight(PayloadTermQuery outerInstance, PayloadTermQuery query, IndexSearcher searcher)
     : base(query, searcher)
 {
     this.OuterInstance = outerInstance;
 }
 public PayloadTermSpanScorer(PayloadTermQuery.PayloadTermWeight outerInstance, TermSpans spans, Weight weight, Similarity.SimScorer docScorer)
     : base(spans, weight, docScorer)
 {
     this.OuterInstance = outerInstance;
     TermSpans = spans;
 }
        public virtual void TestMultipleMatchesPerDoc()
        {
            PayloadTermQuery query = new PayloadTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"), new MaxPayloadFunction());
            TopDocs hits = Searcher.Search(query, null, 100);
            Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
            Assert.IsTrue(hits.TotalHits == 100, "hits Size: " + hits.TotalHits + " is not: " + 100);

            //they should all have the exact same score, because they all contain seventy once, and we set
            //all the other similarity factors to be 1

            //System.out.println("Hash: " + seventyHash + " Twice Hash: " + 2*seventyHash);
            Assert.IsTrue(hits.MaxScore == 4.0, hits.MaxScore + " does not equal: " + 4.0);
            //there should be exactly 10 items that score a 4, all the rest should score a 2
            //The 10 items are: 70 + i*100 where i in [0-9]
            int numTens = 0;
            for (int i = 0; i < hits.ScoreDocs.Length; i++)
            {
                ScoreDoc doc = hits.ScoreDocs[i];
                if (doc.Doc % 10 == 0)
                {
                    numTens++;
                    Assert.IsTrue(doc.Score == 4.0, doc.Score + " does not equal: " + 4.0);
                }
                else
                {
                    Assert.IsTrue(doc.Score == 2, doc.Score + " does not equal: " + 2);
                }
            }
            Assert.IsTrue(numTens == 10, numTens + " does not equal: " + 10);
            CheckHits.CheckExplanations(query, "field", Searcher, true);
            Spans spans = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, query);
            Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
            //should be two matches per document
            int count = 0;
            //100 hits times 2 matches per hit, we should have 200 in count
            while (spans.Next())
            {
                count++;
            }
            Assert.IsTrue(count == 200, count + " does not equal: " + 200);
        }
 public PayloadTermWeight(PayloadTermQuery enclosingInstance, PayloadTermQuery query, Searcher searcher) : base(query, searcher)
 {
     InitBlock(enclosingInstance);
 }
 private PayloadNearQuery NewPhraseQuery(System.String fieldName, System.String phrase, bool inOrder)
 {
     int n;
     System.String[] words = System.Text.RegularExpressions.Regex.Split(phrase, "[\\s]+");
     SpanQuery[] clauses = new SpanQuery[words.Length];
     for (int i = 0; i < clauses.Length; i++)
     {
         clauses[i] = new PayloadTermQuery(new Term(fieldName, words[i]), new AveragePayloadFunction());
     }
     return new PayloadNearQuery(clauses, 0, inOrder);
 }
 private SpanNearQuery SpanNearQuery_Renamed(System.String fieldName, System.String words)
 {
     System.String[] wordList = System.Text.RegularExpressions.Regex.Split(words, "[\\s]+");
     SpanQuery[] clauses = new SpanQuery[wordList.Length];
     for (int i = 0; i < clauses.Length; i++)
     {
         clauses[i] = new PayloadTermQuery(new Term(fieldName, wordList[i]), new AveragePayloadFunction());
     }
     return new SpanNearQuery(clauses, 10000, false);
 }
		public virtual void  Test()
		{
			PayloadTermQuery query = new PayloadTermQuery(new Term("field", "seventy"), new MaxPayloadFunction());
			TopDocs hits = searcher.Search(query, null, 100);
			Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
			Assert.IsTrue(hits.totalHits == 100, "hits Size: " + hits.totalHits + " is not: " + 100);
			
			//they should all have the exact same score, because they all contain seventy once, and we set
			//all the other similarity factors to be 1
			
			Assert.IsTrue(hits.GetMaxScore() == 1, hits.GetMaxScore() + " does not equal: " + 1);
			for (int i = 0; i < hits.scoreDocs.Length; i++)
			{
				ScoreDoc doc = hits.scoreDocs[i];
				Assert.IsTrue(doc.score == 1, doc.score + " does not equal: " + 1);
			}
			CheckHits.CheckExplanations(query, PayloadHelper.FIELD, searcher, true);
			Lucene.Net.Search.Spans.Spans spans = query.GetSpans(searcher.GetIndexReader());
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			Assert.IsTrue(spans is TermSpans, "spans is not an instanceof " + typeof(TermSpans));
            /*float score = hits.score(0);
            for (int i =1; i < hits.length(); i++)
            {
            Assert.IsTrue(score == hits.score(i), "scores are not equal and they should be");
            }*/
        }
 private static void VisitQuery(PayloadTermQuery query, AzureQueryLogger.IndentedTextWriter writer)
 {
     AzureQueryLogger.VisitTerm(query.Term, writer);
 }
 private void InitBlock(PayloadTermQuery enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
 public PayloadTermWeight(PayloadTermQuery enclosingInstance, PayloadTermQuery query, Searcher searcher)
     : base(query, searcher)
 {
     InitBlock(enclosingInstance);
 }
 private SpanNearQuery SpanNearQuery(string fieldName, string words)
 {
     string[] wordList = words.Split("[\\s]+".ToCharArray());
     SpanQuery[] clauses = new SpanQuery[wordList.Length];
     for (int i = 0; i < clauses.Length; i++)
     {
         clauses[i] = new PayloadTermQuery(new Term(fieldName, wordList[i]), new AveragePayloadFunction());
     }
     return new SpanNearQuery(clauses, 10000, false);
 }
		public virtual void  TestNoMatch()
		{
			PayloadTermQuery query = new PayloadTermQuery(new Term(PayloadHelper.FIELD, "junk"), new MaxPayloadFunction());
			TopDocs hits = searcher.Search(query, null, 100);
			Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
			Assert.IsTrue(hits.totalHits == 0, "hits Size: " + hits.totalHits + " is not: " + 0);
		}
		public virtual void  TestNoPayload()
		{
			PayloadTermQuery q1 = new PayloadTermQuery(new Term(PayloadHelper.NO_PAYLOAD_FIELD, "zero"), new MaxPayloadFunction());
			PayloadTermQuery q2 = new PayloadTermQuery(new Term(PayloadHelper.NO_PAYLOAD_FIELD, "foo"), new MaxPayloadFunction());
			BooleanClause c1 = new BooleanClause(q1, BooleanClause.Occur.MUST);
			BooleanClause c2 = new BooleanClause(q2, BooleanClause.Occur.MUST_NOT);
			BooleanQuery query = new BooleanQuery();
			query.Add(c1);
			query.Add(c2);
			TopDocs hits = searcher.Search(query, null, 100);
			Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
			Assert.IsTrue(hits.totalHits == 1, "hits Size: " + hits.totalHits + " is not: " + 1);
			int[] results = new int[1];
			results[0] = 0; //hits.scoreDocs[0].doc;
			CheckHits.CheckHitCollector(query, PayloadHelper.NO_PAYLOAD_FIELD, searcher, results);
		}
 private void  InitBlock(PayloadTermQuery enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
 private SpanNearQuery SpanNearQuery(string fieldName, string words)
 {
     var wordList = _whiteSpaceRegex.Split(words);
     var clauses = new SpanQuery[wordList.Length];
     for (var i = 0; i < clauses.Length; i++)
     {
         clauses[i] = new PayloadTermQuery(new Term(fieldName, wordList[i]), new AveragePayloadFunction());
     }
     return new SpanNearQuery(clauses, 10000, false);
 }
		public virtual void  TestQuery()
		{
			PayloadTermQuery boostingFuncTermQuery = new PayloadTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"), new MaxPayloadFunction());
			QueryUtils.Check(boostingFuncTermQuery);
			
			SpanTermQuery spanTermQuery = new SpanTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"));
			
			Assert.IsTrue(boostingFuncTermQuery.Equals(spanTermQuery) == spanTermQuery.Equals(boostingFuncTermQuery));
			
			PayloadTermQuery boostingFuncTermQuery2 = new PayloadTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"), new AveragePayloadFunction());
			
			QueryUtils.CheckUnequal(boostingFuncTermQuery, boostingFuncTermQuery2);
		}
        public virtual void Test()
        {
            PayloadTermQuery query = new PayloadTermQuery(new Term("field", "seventy"), new MaxPayloadFunction());
            TopDocs hits = Searcher.Search(query, null, 100);
            Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
            Assert.IsTrue(hits.TotalHits == 100, "hits Size: " + hits.TotalHits + " is not: " + 100);

            //they should all have the exact same score, because they all contain seventy once, and we set
            //all the other similarity factors to be 1

            Assert.IsTrue(hits.MaxScore == 1, hits.MaxScore + " does not equal: " + 1);
            for (int i = 0; i < hits.ScoreDocs.Length; i++)
            {
                ScoreDoc doc = hits.ScoreDocs[i];
                Assert.IsTrue(doc.Score == 1, doc.Score + " does not equal: " + 1);
            }
            CheckHits.CheckExplanations(query, PayloadHelper.FIELD, Searcher, true);
            Spans spans = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, query);
            Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
            /*float score = hits.Score(0);
            for (int i =1; i < hits.Length(); i++)
            {
              Assert.IsTrue(score == hits.Score(i), "scores are not equal and they should be");
            }*/
        }
Exemple #31
0
 public PayloadTermWeight(PayloadTermQuery outerInstance, PayloadTermQuery query, IndexSearcher searcher)
     : base(query, searcher)
 {
     this.OuterInstance = outerInstance;
 }
		public virtual void  TestIgnoreSpanScorer()
		{
			PayloadTermQuery query = new PayloadTermQuery(new Term(PayloadHelper.MULTI_FIELD, "seventy"), new MaxPayloadFunction(), false);
			
			IndexSearcher theSearcher = new IndexSearcher(directory, true);
			theSearcher.SetSimilarity(new FullSimilarity());
			TopDocs hits = searcher.Search(query, null, 100);
			Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
			Assert.IsTrue(hits.totalHits == 100, "hits Size: " + hits.totalHits + " is not: " + 100);
			
			//they should all have the exact same score, because they all contain seventy once, and we set
			//all the other similarity factors to be 1
			
			//System.out.println("Hash: " + seventyHash + " Twice Hash: " + 2*seventyHash);
			Assert.IsTrue(hits.GetMaxScore() == 4.0, hits.GetMaxScore() + " does not equal: " + 4.0);
			//there should be exactly 10 items that score a 4, all the rest should score a 2
			//The 10 items are: 70 + i*100 where i in [0-9]
			int numTens = 0;
			for (int i = 0; i < hits.scoreDocs.Length; i++)
			{
				ScoreDoc doc = hits.scoreDocs[i];
				if (doc.doc % 10 == 0)
				{
					numTens++;
					Assert.IsTrue(doc.score == 4.0, doc.score + " does not equal: " + 4.0);
				}
				else
				{
					Assert.IsTrue(doc.score == 2, doc.score + " does not equal: " + 2);
				}
			}
			Assert.IsTrue(numTens == 10, numTens + " does not equal: " + 10);
			CheckHits.CheckExplanations(query, "field", searcher, true);
			Lucene.Net.Search.Spans.Spans spans = query.GetSpans(searcher.GetIndexReader());
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			Assert.IsTrue(spans is TermSpans, "spans is not an instanceof " + typeof(TermSpans));
			//should be two matches per document
			int count = 0;
			//100 hits times 2 matches per hit, we should have 200 in count
			while (spans.Next())
			{
				count++;
			}
		}