Exemple #1
0
        public void ParsingTwoWordsWithAndOperator_ShouldComposeWithAndOperator()
        {
            var result        = this.Parse("wordone & wordtwo");
            var expectedQuery = new AndQueryOperator(new ExactWordQueryPart("wordone"), new ExactWordQueryPart("wordtwo"));

            VerifyResult(result, expectedQuery);
        }
Exemple #2
0
        public void ShouldOnlyReturnItemsAppearingOnBothSides()
        {
            var op = new AndQueryOperator(
                new FakeQueryPart(5, 8, 9),
                new FakeQueryPart(2, 5, 9));

            var result = op.Evaluate(() => new FakeIndexNavigator());

            result.Matches.Select(m => m.ItemId).Should().BeEquivalentTo(
                new[] { 5, 9 });
        }
Exemple #3
0
        public void ShouldMergeIndexedWordsInCorrectOrderForMatchingFields()
        {
            var op = new AndQueryOperator(
                new FakeQueryPart(QueryWordMatch(5, FieldMatch(1, 1, 7), FieldMatch(2, 9, 20))),
                new FakeQueryPart(QueryWordMatch(5, FieldMatch(1, 9), FieldMatch(2, 3, 34))));

            var result = op.Evaluate(() => new FakeIndexNavigator());

            result.Matches.Should().BeEquivalentTo(new[] {
                QueryWordMatch(
                    5,
                    FieldMatch(1, 1, 7, 9),
                    FieldMatch(2, 3, 9, 20, 34))
            });
        }
        public void ShouldMergeIndexedWordsInCorrectOrderForMatchingFields()
        {
            var op = new AndQueryOperator(
                new FakeQueryPart(ScoredToken(5, ScoredFieldMatch(1D, 1, 1, 7), ScoredFieldMatch(3D, 2, 9, 20))),
                new FakeQueryPart(ScoredToken(5, ScoredFieldMatch(2D, 1, 9), ScoredFieldMatch(4D, 2, 3, 34))));

            var result = op.Evaluate(() => new FakeIndexNavigator(), QueryContext.Empty);

            result.Matches.Should().BeEquivalentTo(new[] {
                ScoredToken(
                    5,
                    ScoredFieldMatch(3D, 1, 1, 7, 9),
                    ScoredFieldMatch(7D, 2, 3, 9, 20, 34))
            });
        }
Exemple #5
0
        public void ParsingFieldFilterWithBracketedStatement_ShouldReturnFieldFilterOperatorWithStatementAsChild()
        {
            var result        = this.Parse("testfield=(test | foo) & otherfield=(foo & bar)");
            var expectedQuery =
                new AndQueryOperator(
                    new FieldFilterQueryOperator(
                        "testfield",
                        TestFieldId,
                        new BracketedQueryPart(
                            new OrQueryOperator(new ExactWordQueryPart("test"), new ExactWordQueryPart("foo")))),
                    new FieldFilterQueryOperator(
                        "otherfield",
                        OtherFieldId,
                        new BracketedQueryPart(
                            new AndQueryOperator(new ExactWordQueryPart("foo"), new ExactWordQueryPart("bar")))));

            VerifyResult(result, expectedQuery);
        }