示例#1
0
        public void ParsingTwoWordsWithPrecedingNearOperator_ShouldComposeWithPrecedingNearOperatorWithSpecifiedTolerance(string query, int expectedTolerance)
        {
            var result        = this.Parse(query);
            var expectedQuery = new PrecedingNearQueryOperator(new ExactWordQueryPart("wordone"), new ExactWordQueryPart("wordtwo"), expectedTolerance);

            VerifyResult(result, expectedQuery);
        }
示例#2
0
        public void ShouldOnlyReturnMatchesForAppropriateField()
        {
            var sut = new PrecedingNearQueryOperator(
                new FakeQueryPart(
                    ScoredToken(7, ScoredFieldMatch(1D, 1, 8, 20, 100), ScoredFieldMatch(5D, 2, 9, 14)),
                    ScoredToken(8, ScoredFieldMatch(2D, 1, 11, 101), ScoredFieldMatch(6D, 2, 8, 104))),
                new FakeQueryPart(
                    ScoredToken(7, ScoredFieldMatch(3D, 1, 6, 14, 102)),
                    ScoredToken(8, ScoredFieldMatch(4D, 1, 5, 106), ScoredFieldMatch(7D, 2, 3, 105))));

            var results = sut.Evaluate(() => new FakeIndexNavigator(), QueryContext.Empty);

            // Item 7 matches:
            // Field 1: (100, 102)
            // Field 2: None
            // Item 8 matches:
            // Field 1: (101, 106)
            // Field 2: (104, 105)
            results.Matches.Should().BeEquivalentTo(
                ScoredToken(
                    7,
                    ScoredFieldMatch(4D, 1, CompositeMatch(100, 102))),
                ScoredToken(
                    8,
                    ScoredFieldMatch(6D, 1, CompositeMatch(101, 106)),
                    ScoredFieldMatch(13D, 2, CompositeMatch(104, 105))));
        }
示例#3
0
        public void ParsingTwoWordsWithPrecedingNearOperator_ShouldComposeWithPrecedingNearOperatorWithToleranceOf5ByDefault()
        {
            var result        = this.Parse("wordone ~> wordtwo");
            var expectedQuery = new PrecedingNearQueryOperator(new ExactWordQueryPart("wordone"), new ExactWordQueryPart("wordtwo"), 5);

            VerifyResult(result, expectedQuery);
        }
示例#4
0
        public void ShouldOnlyReturnMatchesForAppropriateField()
        {
            var sut = new PrecedingNearQueryOperator(
                new FakeQueryPart(
                    QueryWordMatch(7, FieldMatch(1, 8, 20, 100), FieldMatch(2, 9, 14)),
                    QueryWordMatch(8, FieldMatch(1, 11, 101), FieldMatch(2, 8, 104))),
                new FakeQueryPart(
                    QueryWordMatch(7, FieldMatch(1, 6, 14, 102)),
                    QueryWordMatch(8, FieldMatch(1, 5, 106), FieldMatch(2, 3, 105))));

            var results = sut.Evaluate(() => new FakeIndexNavigator());

            // Item 7 matches:
            // Field 1: (100, 102)
            // Field 2: None
            // Item 8 matches:
            // Field 1: (101, 106)
            // Field 2: (104, 105)
            results.Matches.Should().BeEquivalentTo(
                QueryWordMatch(
                    7,
                    new FieldMatch(1, CompositeMatch(100, 102))),
                QueryWordMatch(
                    8,
                    new FieldMatch(1, CompositeMatch(101, 106)),
                    new FieldMatch(2, CompositeMatch(104, 105))));
        }