Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnIndexHitsInGivenSortOrder() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnIndexHitsInGivenSortOrder()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(43);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Collect(1);
            collector.Collect(3);
            collector.Collect(37);
            collector.Collect(42);

            // then
            Sort byIdDescending            = new Sort(new SortField("id", SortField.Type.LONG, true));
            IndexHits <Document> indexHits = collector.GetIndexHits(byIdDescending);

            assertEquals(4, indexHits.Size());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("42", indexHits.next().get("id"));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("37", indexHits.next().get("id"));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("3", indexHits.next().get("id"));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("1", indexHits.next().get("id"));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(indexHits.hasNext());
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCollectAllHitsPerSegment() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldCollectAllHitsPerSegment()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector();
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Collect(1);
            collector.Collect(3);
            collector.Collect(5);
            collector.Collect(9);

            // then
            assertEquals(4, collector.TotalHits);
            IList <DocValuesCollector.MatchingDocs> allMatchingDocs = collector.GetMatchingDocs();

            assertEquals(1, allMatchingDocs.Count);
            DocValuesCollector.MatchingDocs matchingDocs = allMatchingDocs[0];
            assertSame(readerStub.Context, matchingDocs.Context);
            assertEquals(4, matchingDocs.TotalHits);
            DocIdSetIterator idIterator = matchingDocs.DocIdSet.GetEnumerator();

            assertEquals(1, idIterator.nextDoc());
            assertEquals(3, idIterator.nextDoc());
            assertEquals(5, idIterator.nextDoc());
            assertEquals(9, idIterator.nextDoc());
            assertEquals(DocIdSetIterator.NO_MORE_DOCS, idIterator.nextDoc());
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnIndexHitsOrderedByRelevance() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnIndexHitsOrderedByRelevance()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(true);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Scorer = ConstantScorer(1.0f);
            collector.Collect(1);
            collector.Scorer = ConstantScorer(2.0f);
            collector.Collect(2);

            // then
            IndexHits <Document> indexHits = collector.GetIndexHits(Sort.RELEVANCE);

            assertEquals(2, indexHits.Size());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("2", indexHits.next().get("id"));
            assertEquals(2.0f, indexHits.CurrentScore(), 0.001f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("1", indexHits.next().get("id"));
            assertEquals(1.0f, indexHits.CurrentScore(), 0.001f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(indexHits.hasNext());
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldStartWithEmptyMatchingDocs()
        internal void ShouldStartWithEmptyMatchingDocs()
        {
            //given
            DocValuesCollector collector = new DocValuesCollector();

            // when
            // then
            assertEquals(emptyList(), collector.GetMatchingDocs());
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnEmptyIteratorWhenNoDocValuesInOrder() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnEmptyIteratorWhenNoDocValuesInOrder()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);

            // then
            LongIterator valuesIterator = collector.GetSortedValuesIterator("id", Sort.RELEVANCE);

            assertFalse(valuesIterator.hasNext());
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnEmptyIteratorWhenNoDocValues()
        internal void ShouldReturnEmptyIteratorWhenNoDocValues()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);

            // then
            DocValuesCollector.LongValuesIterator valuesIterator = collector.GetValuesIterator("id");
            assertEquals(0, valuesIterator.Remaining());
            assertFalse(valuesIterator.HasNext());
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotSaveScoresWhenNotRequired() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldNotSaveScoresWhenNotRequired()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Collect(1);

            // then
            DocValuesCollector.MatchingDocs matchingDocs = collector.GetMatchingDocs()[0];
            assertNull(matchingDocs.Scores);
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSaveScoresWhenRequired() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldSaveScoresWhenRequired()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(true);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Scorer = ConstantScorer(13.42f);
            collector.Collect(1);

            // then
            DocValuesCollector.MatchingDocs matchingDocs = collector.GetMatchingDocs()[0];
            assertArrayEquals(new float[] { 13.42f }, matchingDocs.Scores, 0.001f);
        }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnEmptyIteratorWhenNoHits() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnEmptyIteratorWhenNoHits()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);

            // then
            IndexHits <Document> indexHits = collector.GetIndexHits(null);

            assertEquals(0, indexHits.Size());
            assertEquals(Float.NaN, indexHits.CurrentScore(), 0.001f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(indexHits.hasNext());
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnDocValuesInIndexOrderWhenNoSortIsGiven() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnDocValuesInIndexOrderWhenNoSortIsGiven()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Collect(1);
            collector.Collect(2);

            // then
            LongIterator valuesIterator = collector.GetSortedValuesIterator("id", null);

            assertEquals(1, valuesIterator.next());
            assertEquals(2, valuesIterator.next());
            assertFalse(valuesIterator.hasNext());
        }
Exemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReadDocValuesInIndexOrder() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReadDocValuesInIndexOrder()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Collect(1);
            collector.Collect(2);

            // then
            DocValuesCollector.LongValuesIterator valuesIterator = collector.GetValuesIterator("id");
            assertEquals(2, valuesIterator.Remaining());
            assertEquals(1, valuesIterator.Next());
            assertEquals(2, valuesIterator.Next());
            assertFalse(valuesIterator.HasNext());
        }
Exemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnDocValuesInGivenOrder() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnDocValuesInGivenOrder()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Collect(1);
            collector.Collect(2);

            // then
            Sort         byIdDescending = new Sort(new SortField("id", SortField.Type.LONG, true));
            LongIterator valuesIterator = collector.GetSortedValuesIterator("id", byIdDescending);

            assertEquals(2, valuesIterator.next());
            assertEquals(1, valuesIterator.next());
            assertFalse(valuesIterator.hasNext());
        }
Exemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnDocValuesInRelevanceOrder() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnDocValuesInRelevanceOrder()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(true);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Scorer = ConstantScorer(1.0f);
            collector.Collect(1);
            collector.Scorer = ConstantScorer(2.0f);
            collector.Collect(2);

            // then
            LongIterator valuesIterator = collector.GetSortedValuesIterator("id", Sort.RELEVANCE);

            assertEquals(2, valuesIterator.next());
            assertEquals(1, valuesIterator.next());
            assertFalse(valuesIterator.hasNext());
        }
Exemplo n.º 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldDynamicallyResizeScoresArray() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldDynamicallyResizeScoresArray()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(true);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Scorer = ConstantScorer(1.0f);
            // scores starts with array size of 32, adding 42 docs forces resize
            for (int i = 0; i < 42; i++)
            {
                collector.Collect(i);
            }

            // then
            DocValuesCollector.MatchingDocs matchingDocs = collector.GetMatchingDocs()[0];
            float[] scores = new float[42];
            Arrays.fill(scores, 1.0f);
            assertArrayEquals(scores, matchingDocs.Scores, 0.001f);
        }
Exemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnIndexHitsInIndexOrderWhenNoSortIsGiven() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnIndexHitsInIndexOrderWhenNoSortIsGiven()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector();
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Collect(1);
            collector.Collect(2);

            // then
            IndexHits <Document> indexHits = collector.GetIndexHits(null);

            assertEquals(2, indexHits.Size());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("1", indexHits.next().get("id"));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("2", indexHits.next().get("id"));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(indexHits.hasNext());
        }