Skip to content

Commit

Permalink
Adjacent words: prevent the same token matching with itself (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikegoatly authored Feb 11, 2022
1 parent 0ae4424 commit 16776df
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trigger:
variables:
majorVersion: 3
minorVersion: 0
patchVersion: 0
patchVersion: 1
project: src/Lifti.Core/Lifti.Core.csproj
testProject: test/Lifti.Tests/Lifti.Tests.csproj
buildConfiguration: 'Release'
Expand Down
1 change: 0 additions & 1 deletion src/Lifti.Core/Lifti.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<PackageId>Lifti.Core</PackageId>
<Copyright>Mike Goatly</Copyright>
<PackageLicenseFile></PackageLicenseFile>
<PackageReleaseNotes>First version of the new rewrite</PackageReleaseNotes>
<AssemblyName>Lifti.Core</AssemblyName>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/Lifti.Core/Querying/IntegerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal static class IntegerExtensions
{
internal static bool IsPositiveAndLessThanOrEqualTo(this int value, int target)
{
return value >= 0 && value <= target;
return value > 0 && value <= target;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,22 @@ public void ShouldOnlyReturnMatchesForAppropriateField()
},
config => config.AllowingInfiniteRecursion());
}

[Fact]
public void ShouldNotCombineSameTokensTogether()
{
var sut = new AdjacentWordsQueryOperator(
new[] {
new FakeQueryPart(
ScoredToken(7, ScoredFieldMatch(1D, 1, 8, 20, 100))),
new FakeQueryPart(
ScoredToken(7, ScoredFieldMatch(1D, 1, 8, 20, 100)))
});

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

// The first and second query parts should not combine together
results.Matches.Should().BeEmpty();
}
}
}

0 comments on commit 16776df

Please sign in to comment.