public void TestAdvanceValidationForToChildBjq()
        {
            int randomChildNumber = GetRandomChildNumber(0);
            // we need to make advance method meet wrong document, so random child number
            // in BJQ must be greater than child number in Boolean clause
            int   nextRandomChildNumber      = GetRandomChildNumber(randomChildNumber);
            Query parentQueryWithRandomChild = CreateParentsQueryWithOneChild(nextRandomChildNumber);
            var   blockJoinQuery             = new ToChildBlockJoinQuery(parentQueryWithRandomChild, parentsFilter, false);
            // advance() method is used by ConjunctionScorer, so we need to create Boolean conjunction query
            var conjunctionQuery = new BooleanQuery();
            var childQuery       = new WildcardQuery(new Term("child", CreateFieldValue(randomChildNumber)));

            conjunctionQuery.Add(new BooleanClause(childQuery, Occur.MUST));
            conjunctionQuery.Add(new BooleanClause(blockJoinQuery, Occur.MUST));

            // LUCENENET: Refactored to allow us to use our IsIllegalStateException() extension method
            try
            {
                indexSearcher.Search(conjunctionQuery, 1);
                fail();
            }
            catch (Exception ise) when(ise.IsIllegalStateException())
            {
                assertTrue(ise.Message.Contains(ToChildBlockJoinQuery.INVALID_QUERY_MESSAGE));
            }
        }
Exemplo n.º 2
0
        public void TestNextDocValidationForToChildBjq()
        {
            Query parentQueryWithRandomChild = CreateParentsQueryWithOneChild(GetRandomChildNumber(0));
            var   blockJoinQuery             = new ToChildBlockJoinQuery(parentQueryWithRandomChild, ParentsFilter, false);

            var ex = Throws <InvalidOperationException>(() => IndexSearcher.Search(blockJoinQuery, 1));

            StringAssert.Contains(ToChildBlockJoinQuery.InvalidQueryMessage, ex.Message);
        }
        public void TestNextDocValidationForToChildBjq()
        {
            Query parentQueryWithRandomChild = CreateParentsQueryWithOneChild(GetRandomChildNumber(0));
            var   blockJoinQuery             = new ToChildBlockJoinQuery(parentQueryWithRandomChild, parentsFilter, false);

            // LUCENENET: Refactored to allow us to use our IsIllegalStateException() extension method
            try
            {
                indexSearcher.Search(blockJoinQuery, 1);
                fail();
            }
            catch (Exception ise) when(ise.IsIllegalStateException())
            {
                assertTrue(ise.Message.Contains(ToChildBlockJoinQuery.INVALID_QUERY_MESSAGE));
            }
        }
Exemplo n.º 4
0
        public void TestAdvanceValidationForToChildBjq()
        {
            int randomChildNumber = GetRandomChildNumber(0);
            // we need to make advance method meet wrong document, so random child number
            // in BJQ must be greater than child number in Boolean clause
            int   nextRandomChildNumber      = GetRandomChildNumber(randomChildNumber);
            Query parentQueryWithRandomChild = CreateParentsQueryWithOneChild(nextRandomChildNumber);
            var   blockJoinQuery             = new ToChildBlockJoinQuery(parentQueryWithRandomChild, ParentsFilter, false);
            // advance() method is used by ConjunctionScorer, so we need to create Boolean conjunction query
            var conjunctionQuery = new BooleanQuery();
            var childQuery       = new WildcardQuery(new Term("child", CreateFieldValue(randomChildNumber)));

            conjunctionQuery.Add(new BooleanClause(childQuery, BooleanClause.Occur.MUST));
            conjunctionQuery.Add(new BooleanClause(blockJoinQuery, BooleanClause.Occur.MUST));

            var ex = Throws <InvalidOperationException>(() => IndexSearcher.Search(conjunctionQuery, 1));

            StringAssert.Contains(ToChildBlockJoinQuery.InvalidQueryMessage, ex.Message);
        }