public virtual void TestFieldCacheRangeFilterDoubles() { IndexReader reader = SignedIndexReader; IndexSearcher search = NewSearcher(reader); int numDocs = reader.NumDocs; double?minIdO = Convert.ToDouble(MinId + .5); double?medIdO = Convert.ToDouble((float)minIdO + ((MaxId - MinId)) / 2.0); ScoreDoc[] result; Query q = new TermQuery(new Term("body", "body")); result = search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", minIdO, medIdO, T, T), numDocs).ScoreDocs; Assert.AreEqual(numDocs / 2, result.Length, "find all"); int count = 0; result = search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", null, medIdO, F, T), numDocs).ScoreDocs; count += result.Length; result = search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", medIdO, null, F, F), numDocs).ScoreDocs; count += result.Length; Assert.AreEqual(numDocs, count, "sum of two concenatted ranges"); result = search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", null, null, T, T), numDocs).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "find all"); result = search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", Convert.ToDouble(double.PositiveInfinity), null, F, F), numDocs).ScoreDocs; Assert.AreEqual(0, result.Length, "infinity special case"); result = search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", null, Convert.ToDouble(double.NegativeInfinity), F, F), numDocs).ScoreDocs; Assert.AreEqual(0, result.Length, "infinity special case"); }
public override bool Equals(System.Object o) { if (this == o) { return(true); } if (!(o is FieldCacheRangeFilter)) { return(false); } FieldCacheRangeFilter other = (FieldCacheRangeFilter)o; if (!this.field.Equals(other.field) || this.includeLower != other.includeLower || this.includeUpper != other.includeUpper) { return(false); } if (this.lowerVal != null?!this.lowerVal.Equals(other.lowerVal):other.lowerVal != null) { return(false); } if (this.upperVal != null?!this.upperVal.Equals(other.upperVal):other.upperVal != null) { return(false); } if (this.parser != null?!this.parser.Equals(other.parser):other.parser != null) { return(false); } return(true); }
public virtual void TestIsCacheAble() { Directory dir = NewDirectory(); RandomIndexWriter writer = new RandomIndexWriter( #if FEATURE_INSTANCE_TESTDATA_INITIALIZATION this, #endif Random, dir); writer.AddDocument(new Document()); writer.Dispose(); IndexReader reader = SlowCompositeReaderWrapper.Wrap(DirectoryReader.Open(dir)); // not cacheable: AssertDocIdSetCacheable(reader, new QueryWrapperFilter(new TermQuery(new Term("test", "value"))), false); // returns default empty docidset, always cacheable: AssertDocIdSetCacheable(reader, NumericRangeFilter.NewInt32Range("test", Convert.ToInt32(10000), Convert.ToInt32(-10000), true, true), true); // is cacheable: AssertDocIdSetCacheable(reader, FieldCacheRangeFilter.NewInt32Range("test", Convert.ToInt32(10), Convert.ToInt32(20), true, true), true); // a fixedbitset filter is always cacheable AssertDocIdSetCacheable(reader, new FilterAnonymousInnerClassHelper3(this), true); reader.Dispose(); dir.Dispose(); }
public virtual void TestFieldCacheRangeFilterRand() { IndexReader reader = IndexReader.Open((Directory)signedIndex.index, true, null); IndexSearcher Search = new IndexSearcher(reader); System.String minRP = Pad(signedIndex.minR); System.String maxRP = Pad(signedIndex.maxR); int numDocs = reader.NumDocs(); Assert.AreEqual(numDocs, 1 + maxId - minId, "num of docs"); ScoreDoc[] result; Query q = new TermQuery(new Term("body", "body")); // test extremes, bounded on both ends result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", minRP, maxRP, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "find all"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", minRP, maxRP, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "all but biggest"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", minRP, maxRP, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "all but smallest"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", minRP, maxRP, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 2, result.Length, "all but extremes"); // unbounded result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", minRP, null, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "smallest and up"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", null, maxRP, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "biggest and down"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", minRP, null, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "not smallest, but up"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", null, maxRP, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "not biggest, but down"); // very small sets result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", minRP, minRP, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "min,min,F,F"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", maxRP, maxRP, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "max,max,F,F"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", minRP, minRP, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "min,min,T,T"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", null, minRP, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "nul,min,F,T"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", maxRP, maxRP, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "max,max,T,T"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("rand", maxRP, null, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "max,nul,T,T"); }
public virtual void TestFieldCacheRangeFilterDoubles() { IndexReader reader = IndexReader.Open((Directory)signedIndex.index, true, null); IndexSearcher Search = new IndexSearcher(reader); int numDocs = reader.NumDocs(); System.Double minIdO = (double)(minId + .5); System.Double medIdO = (double)((float)minIdO + ((double)(maxId - minId)) / 2.0); ScoreDoc[] result; Query q = new TermQuery(new Term("body", "body")); result = Search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", minIdO, medIdO, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs / 2, result.Length, "find all"); int count = 0; result = Search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", null, medIdO, F, T), numDocs, null).ScoreDocs; count += result.Length; result = Search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", medIdO, null, F, F), numDocs, null).ScoreDocs; count += result.Length; Assert.AreEqual(numDocs, count, "sum of two concenatted ranges"); result = Search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", null, null, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "find all"); System.Double tempAux = (double)System.Double.PositiveInfinity; result = Search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", tempAux, null, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "infinity special case"); System.Double tempAux2 = (double)System.Double.NegativeInfinity; result = Search.Search(q, FieldCacheRangeFilter.NewDoubleRange("id", null, tempAux2, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "infinity special case"); }
// test using a sparse index (with deleted docs). The DocIdSet should be not cacheable, as it uses TermDocs if the range contains 0 public void TestSparseIndex() { RAMDirectory dir = new RAMDirectory(); IndexWriter writer = new IndexWriter(dir, new SimpleAnalyzer(), T, IndexWriter.MaxFieldLength.LIMITED, null); for (int d = -20; d <= 20; d++) { Document doc = new Document(); doc.Add(new Field("id", d.ToString(), Field.Store.NO, Field.Index.NOT_ANALYZED)); doc.Add(new Field("body", "body", Field.Store.NO, Field.Index.NOT_ANALYZED)); writer.AddDocument(doc, null); } writer.Optimize(null); writer.DeleteDocuments(null, new Term("id", "0")); writer.Close(); IndexReader reader = IndexReader.Open((Directory)dir, true, null); IndexSearcher Search = new IndexSearcher(reader); Assert.True(reader.HasDeletions); ScoreDoc[] result; Query q = new TermQuery(new Term("body", "body")); FieldCacheRangeFilter <sbyte?> fcrf; result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", -20, 20, T, T), 100, null).ScoreDocs; Assert.False(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0], null).IsCacheable, "DocIdSet must be not cacheable"); Assert.AreEqual(40, result.Length, "find all"); result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", 0, 20, T, T), 100, null).ScoreDocs; Assert.False(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0], null).IsCacheable, "DocIdSet must be not cacheable"); Assert.AreEqual(20, result.Length, "find all"); result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", -20, 0, T, T), 100, null).ScoreDocs; Assert.False(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0], null).IsCacheable, "DocIdSet must be not cacheable"); Assert.AreEqual(20, result.Length, "find all"); result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", 10, 20, T, T), 100, null).ScoreDocs; Assert.True(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0], null).IsCacheable, "DocIdSet must be not cacheable"); Assert.AreEqual(11, result.Length, "find all"); result = Search.Search(q, fcrf = FieldCacheRangeFilter.NewByteRange("id", -20, -10, T, T), 100, null).ScoreDocs; Assert.True(fcrf.GetDocIdSet(reader.GetSequentialSubReaders()[0], null).IsCacheable, "DocIdSet must be not cacheable"); Assert.AreEqual(11, result.Length, "find all"); }
public virtual void TestSparseIndex() { Directory dir = NewDirectory(); IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))); for (int d = -20; d <= 20; d++) { Document doc = new Document(); doc.Add(NewStringField("id", Convert.ToString(d, CultureInfo.InvariantCulture), Field.Store.NO)); doc.Add(NewStringField("body", "body", Field.Store.NO)); writer.AddDocument(doc); } writer.ForceMerge(1); writer.DeleteDocuments(new Term("id", "0")); writer.Dispose(); IndexReader reader = DirectoryReader.Open(dir); IndexSearcher search = NewSearcher(reader); Assert.IsTrue(reader.HasDeletions); ScoreDoc[] result; Query q = new TermQuery(new Term("body", "body")); #pragma warning disable 612, 618 result = search.Search(q, FieldCacheRangeFilter.NewByteRange("id", (sbyte?)-20, (sbyte?)20, T, T), 100).ScoreDocs; Assert.AreEqual(40, result.Length, "find all"); result = search.Search(q, FieldCacheRangeFilter.NewByteRange("id", (sbyte?)0, (sbyte?)20, T, T), 100).ScoreDocs; Assert.AreEqual(20, result.Length, "find all"); result = search.Search(q, FieldCacheRangeFilter.NewByteRange("id", (sbyte?)-20, (sbyte?)0, T, T), 100).ScoreDocs; Assert.AreEqual(20, result.Length, "find all"); result = search.Search(q, FieldCacheRangeFilter.NewByteRange("id", (sbyte?)10, (sbyte?)20, T, T), 100).ScoreDocs; Assert.AreEqual(11, result.Length, "find all"); result = search.Search(q, FieldCacheRangeFilter.NewByteRange("id", (sbyte?)-20, (sbyte?)-10, T, T), 100).ScoreDocs; Assert.AreEqual(11, result.Length, "find all"); #pragma warning restore 612, 618 reader.Dispose(); dir.Dispose(); }
public void TestIsCacheable() { Directory dir = new RAMDirectory(); IndexWriter writer = new IndexWriter(dir, new KeywordAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); writer.Close(); IndexReader reader = IndexReader.Open(dir, true); // not cacheable: assertDocIdSetCacheable(reader, new QueryWrapperFilter(new TermQuery(new Term("test", "value"))), false); // returns default empty docidset, always cacheable: assertDocIdSetCacheable(reader, NumericRangeFilter.NewIntRange("test", 10000, -10000, true, true), true); // is cacheable: assertDocIdSetCacheable(reader, FieldCacheRangeFilter.NewIntRange("test", 10, 20, true, true), true); // a openbitset filter is always cacheable assertDocIdSetCacheable(reader, new AnonymousFilter3(), true); reader.Close(); }
private void InitBlock(long[] values, long inclusiveLowerPoint, long inclusiveUpperPoint, FieldCacheRangeFilter <long?> enclosingInstance) { this.values = values; this.inclusiveLowerPoint = inclusiveLowerPoint; this.inclusiveUpperPoint = inclusiveUpperPoint; this.enclosingInstance = enclosingInstance; }
public virtual void TestRangeFilterId() { IndexReader reader = IndexReader.Open((Directory)signedIndex.index, true, null); IndexSearcher Search = new IndexSearcher(reader); int medId = ((maxId - minId) / 2); System.String minIP = Pad(minId); System.String maxIP = Pad(maxId); System.String medIP = Pad(medId); int numDocs = reader.NumDocs(); Assert.AreEqual(numDocs, 1 + maxId - minId, "num of docs"); ScoreDoc[] result; Query q = new TermQuery(new Term("body", "body")); // test id, bounded on both ends result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, maxIP, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "find all"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, maxIP, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "all but last"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, maxIP, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "all but first"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, maxIP, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 2, result.Length, "all but ends"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", medIP, maxIP, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1 + maxId - medId, result.Length, "med and up"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, medIP, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1 + medId - minId, result.Length, "up to med"); // unbounded id result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", null, null, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "find all"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, null, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "min and up"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", null, maxIP, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "max and down"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, null, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "not min, but up"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", null, maxIP, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "not max, but down"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", medIP, maxIP, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(maxId - medId, result.Length, "med and up, not max"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, medIP, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(medId - minId, result.Length, "not min, up to med"); // very small sets result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, minIP, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "min,min,F,F"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", medIP, medIP, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "med,med,F,F"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", maxIP, maxIP, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "max,max,F,F"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", minIP, minIP, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "min,min,T,T"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", null, minIP, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "nul,min,F,T"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", maxIP, maxIP, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "max,max,T,T"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", maxIP, null, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "max,nul,T,T"); result = Search.Search(q, FieldCacheRangeFilter.NewStringRange("id", medIP, medIP, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "med,med,T,T"); }
public virtual void TestFieldCacheRangeFilterLongs() { IndexReader reader = IndexReader.Open((Directory)signedIndex.index, true, null); IndexSearcher Search = new IndexSearcher(reader); int numDocs = reader.NumDocs(); int medId = ((maxId - minId) / 2); System.Int64 minIdO = (long)minId; System.Int64 maxIdO = (long)maxId; System.Int64 medIdO = (long)medId; Assert.AreEqual(numDocs, 1 + maxId - minId, "num of docs"); ScoreDoc[] result; Query q = new TermQuery(new Term("body", "body")); // test id, bounded on both ends result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, maxIdO, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "find all"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, maxIdO, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "all but last"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, maxIdO, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "all but first"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, maxIdO, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 2, result.Length, "all but ends"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", medIdO, maxIdO, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1 + maxId - medId, result.Length, "med and up"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, medIdO, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1 + medId - minId, result.Length, "up to med"); // unbounded id result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, null, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "find all"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, null, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "min and up"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, maxIdO, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "max and down"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, null, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "not min, but up"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, maxIdO, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "not max, but down"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", medIdO, maxIdO, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(maxId - medId, result.Length, "med and up, not max"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, medIdO, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(medId - minId, result.Length, "not min, up to med"); // very small sets result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, minIdO, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "min,min,F,F"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", medIdO, medIdO, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "med,med,F,F"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", maxIdO, maxIdO, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "max,max,F,F"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, minIdO, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "min,min,T,T"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, minIdO, F, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "nul,min,F,T"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", maxIdO, maxIdO, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "max,max,T,T"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", maxIdO, null, T, F), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "max,nul,T,T"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", medIdO, medIdO, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(1, result.Length, "med,med,T,T"); // special cases System.Int64 tempAux = (long)System.Int64.MaxValue; result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", tempAux, null, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "overflow special case"); System.Int64 tempAux2 = (long)System.Int64.MinValue; result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, tempAux2, F, F), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "overflow special case"); result = Search.Search(q, FieldCacheRangeFilter.NewLongRange("id", maxIdO, minIdO, T, T), numDocs, null).ScoreDocs; Assert.AreEqual(0, result.Length, "inverse range"); }
private void InitBlock(float[] values, float inclusiveLowerPoint, float inclusiveUpperPoint, FieldCacheRangeFilter <float?> enclosingInstance) { this.values = values; this.inclusiveLowerPoint = inclusiveLowerPoint; this.inclusiveUpperPoint = inclusiveUpperPoint; this.enclosingInstance = enclosingInstance; }
public virtual void TestFieldCacheRangeFilterLongs() { IndexReader reader = SignedIndexReader; IndexSearcher search = NewSearcher(reader); int numDocs = reader.NumDocs; int medId = ((MaxId - MinId) / 2); long?minIdO = Convert.ToInt64(MinId); long?maxIdO = Convert.ToInt64(MaxId); long?medIdO = Convert.ToInt64(medId); Assert.AreEqual(numDocs, 1 + MaxId - MinId, "num of docs"); ScoreDoc[] result; Query q = new TermQuery(new Term("body", "body")); // test id, bounded on both ends result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, maxIdO, T, T), numDocs).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "find all"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, maxIdO, T, F), numDocs).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "all but last"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, maxIdO, F, T), numDocs).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "all but first"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, maxIdO, F, F), numDocs).ScoreDocs; Assert.AreEqual(numDocs - 2, result.Length, "all but ends"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", medIdO, maxIdO, T, T), numDocs).ScoreDocs; Assert.AreEqual(1 + MaxId - medId, result.Length, "med and up"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, medIdO, T, T), numDocs).ScoreDocs; Assert.AreEqual(1 + medId - MinId, result.Length, "up to med"); // unbounded id result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, null, T, T), numDocs).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "find all"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, null, T, F), numDocs).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "min and up"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, maxIdO, F, T), numDocs).ScoreDocs; Assert.AreEqual(numDocs, result.Length, "max and down"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, null, F, F), numDocs).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "not min, but up"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, maxIdO, F, F), numDocs).ScoreDocs; Assert.AreEqual(numDocs - 1, result.Length, "not max, but down"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", medIdO, maxIdO, T, F), numDocs).ScoreDocs; Assert.AreEqual(MaxId - medId, result.Length, "med and up, not max"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, medIdO, F, T), numDocs).ScoreDocs; Assert.AreEqual(medId - MinId, result.Length, "not min, up to med"); // very small sets result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, minIdO, F, F), numDocs).ScoreDocs; Assert.AreEqual(0, result.Length, "min,min,F,F"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", medIdO, medIdO, F, F), numDocs).ScoreDocs; Assert.AreEqual(0, result.Length, "med,med,F,F"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", maxIdO, maxIdO, F, F), numDocs).ScoreDocs; Assert.AreEqual(0, result.Length, "max,max,F,F"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", minIdO, minIdO, T, T), numDocs).ScoreDocs; Assert.AreEqual(1, result.Length, "min,min,T,T"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, minIdO, F, T), numDocs).ScoreDocs; Assert.AreEqual(1, result.Length, "nul,min,F,T"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", maxIdO, maxIdO, T, T), numDocs).ScoreDocs; Assert.AreEqual(1, result.Length, "max,max,T,T"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", maxIdO, null, T, F), numDocs).ScoreDocs; Assert.AreEqual(1, result.Length, "max,nul,T,T"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", medIdO, medIdO, T, T), numDocs).ScoreDocs; Assert.AreEqual(1, result.Length, "med,med,T,T"); // special cases result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", Convert.ToInt64(long.MaxValue), null, F, F), numDocs).ScoreDocs; Assert.AreEqual(0, result.Length, "overflow special case"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", null, Convert.ToInt64(long.MinValue), F, F), numDocs).ScoreDocs; Assert.AreEqual(0, result.Length, "overflow special case"); result = search.Search(q, FieldCacheRangeFilter.NewLongRange("id", maxIdO, minIdO, T, T), numDocs).ScoreDocs; Assert.AreEqual(0, result.Length, "inverse range"); }
internal AnonymousClassFieldCacheDocIdSet(Lucene.Net.Search.StringIndex fcsi, int inclusiveLowerPoint, int inclusiveUpperPoint, FieldCacheRangeFilter <string> enclosingInstance, Lucene.Net.Index.IndexReader Param1, bool Param2) : base(Param1, Param2) { InitBlock(fcsi, inclusiveLowerPoint, inclusiveUpperPoint, enclosingInstance); }
private void InitBlock(Lucene.Net.Search.StringIndex fcsi, int inclusiveLowerPoint, int inclusiveUpperPoint, FieldCacheRangeFilter <string> enclosingInstance) { this.fcsi = fcsi; this.inclusiveLowerPoint = inclusiveLowerPoint; this.inclusiveUpperPoint = inclusiveUpperPoint; this.enclosingInstance = enclosingInstance; }
internal AnonymousClassFieldCacheDocIdSet(double[] values, double inclusiveLowerPoint, double inclusiveUpperPoint, FieldCacheRangeFilter <double?> enclosingInstance, Lucene.Net.Index.IndexReader Param1, bool Param2) : base(Param1, Param2) { InitBlock(values, inclusiveLowerPoint, inclusiveUpperPoint, enclosingInstance); }
private void InitBlock(double[] values, double inclusiveLowerPoint, double inclusiveUpperPoint, FieldCacheRangeFilter <double?> enclosingInstance) { this.values = values; this.inclusiveLowerPoint = inclusiveLowerPoint; this.inclusiveUpperPoint = inclusiveUpperPoint; this.enclosingInstance = enclosingInstance; }